How can i use yield from in Protocal?

22 views
Skip to first unread message

Bright Pan

unread,
Mar 20, 2016, 1:52:27 AM3/20/16
to python-pulsar
i want to run an coroutine in protocal,  but is failue : RuntimeError: Event loop is running.

how do it?

 for example:

class EchoServerProtocol(EchoProtocol):
'''The :class:`EchoProtocol` used by the echo :func:`server`.
'''
@asyncio.coroutine
def do_find_one(self):
        return '23567898'
 
    def response(self, data, rest):
self.transport.write(data)
data = data[:-len(self.separator)]
self.connection.logger.info(data)
phone = self._loop.run_until_complete(self.do_fine_one())
self.connection.logger.info(phone)
# If we get a QUIT message, close the transport.
# Used by the test suite.
if data == b'QUIT':
self.transport.close()
return data
Reply all
Reply to author
Forward
0 new messages