async def run_amqp_listener():
listener = ReconnectingConsumer(CONFIG.Configuration['AMQP'])
listener.run()
async def main():
listen_task = asyncio.create_task(run_amqp_listener())
await asyncio.gather(listener_task, other_tasks)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
File "/home/pi/mesh_blue/lib/python3.7/site-packages/mesh_edge/gateway/listener.py", line 377, in run self._consumer.run() File "/home/pi/mesh_blue/lib/python3.7/site-packages/mesh_edge/gateway/listener.py", line 339, in run self._connection.ioloop.run_forever() File "/usr/local/lib/python3.7/asyncio/base_events.py", line 521, in run_forever raise RuntimeError('This event loop is already running')RuntimeError: This event loop is already running
def connect(self):
LOGGER.info('Connecting to %s', self._url)
return AsyncioConnection(
parameters=pika.URLParameters(self._url),
on_open_callback=self.on_connection_open,
on_open_error_callback=self.on_connection_open_error,
on_close_callback=self.on_connection_closed),
custom_ioloop=asyncio.get_running_loop())
self._connection.ioloop.create_future()
import asyncio
from listener import ReconnectingExampleConsumer
async def Random():
while True:
await asyncio.sleep(2)
print('[*] Random!')
async def Listener():
uri = 'amqp://guest:guest@localhost:5672/%2F'
listener = ReconnectingExampleConsumer(uri)
listener.run()
async def main():
random_task = Random()
listen_task = Listener()
await asyncio.gather(random_task, listen_task)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
import asyncio
from listener import ReconnectingExampleConsumer
async def Random():
while True:
await asyncio.sleep(2)
print('[*] Random!')
async def Listener():
uri = 'amqp://guest:guest@localhost:5672/%2F'
listener = ReconnectingExampleConsumer(uri)
listener.run()
async def main():
random_task = asyncio.create_task(Random())
listen_task = asyncio.create_task(Listener())
await asyncio.gather(random_task)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())