pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 891 forks source link

attached to a different loop #2105

Closed pbubas closed 3 months ago

pbubas commented 3 months ago

Versions

Pymodbus Specific

Description

I noticed below issue in 3.6.6, In 3.5.2 issue is not ocurring

function that i'm calling is 'read_modbus_objects': https://github.com/pbubas/modbus_wrapper/blob/dc654debbec328972fe07dd6c5b65a3c28dfbef9/modbus_wrapper/clients/asynchronous.py#L31

Code and Logs

 | RuntimeError: Task <Task pending name='Task-14' coro=<BaseEventLoop.create_connection() running at /usr/local/lib/python3.11/asyncio/base_events.py:1070> cb=[_release_waiter(<Future pendi...ask_wakeup()]>)() at /usr/local/lib/python3.11/asyncio/tasks.py:431]> got Future <Future pending cb=[BaseSelectorEventLoop._sock_write_done(20, handle=<Handle BaseS....3.30', 502))>)()]> attached to a different loop
 |            ^^^^^^^^^
 |            ^^^^^^^^^
 | RuntimeError: Task <Task pending name='Task-10' coro=<BaseEventLoop.create_connection() running at /usr/local/lib/python3.11/asyncio/base_events.py:1070> cb=[_release_waiter(<Future pendi...ask_wakeup()]>)() at /usr/local/lib/python3.11/asyncio/tasks.py:431]> got Future <Future pending cb=[BaseSelectorEventLoop._sock_write_done(21, handle=<Handle BaseS....3.30', 502))>)()]> attached to a different loop
 | RuntimeError: Task <Task pending name='Task-6' coro=<BaseEventLoop.create_connection() running at /usr/local/lib/python3.11/asyncio/base_events.py:1070> cb=[_release_waiter(<Future pendi...ask_wakeup()]>)() at /usr/local/lib/python3.11/asyncio/tasks.py:431]> got Future <Future pending cb=[BaseSelectorEventLoop._sock_write_done(20, handle=<Handle BaseS....3.30', 502))>)()]> attached to a different loop
janiversen commented 3 months ago

The calls need to execute in the same loop where you created the client.

And yes it might have worked in 3.5.4, because there we assigned the loop in the first cal.