Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quamash loop and asyncio.open_connection error! #89

Open
dpineiden opened this issue Jan 19, 2018 · 4 comments
Open

Quamash loop and asyncio.open_connection error! #89

dpineiden opened this issue Jan 19, 2018 · 4 comments

Comments

@dpineiden
Copy link

dpineiden commented Jan 19, 2018

Hello Guys!

I'm David and i'm working now with your module and pyqt. Also y have a loop to obtain data from a database 'Rethinkdb' that uses asyncio also, so in the quamash loop i have to put this loop on the Rethinkdb class and open the connection.
The problem itself is in the asyncio module, when throw a lot of functions pass the quamash loop to the 'create_connection'.
This is the error:

  File "/home/dpineda/.virtualenvs/dragoncharts/lib/python3.6/site-packages/rethinkdb/asyncio_net/net_asyncio.py", line 148, in connect
    loop=self._io_loop)
  File "/usr/local/lib/python3.6/asyncio/streams.py", line 76, in open_connection
    lambda: protocol, host, port, **kwds)
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 731, in create_connection
    yield from tasks.wait(fs, loop=self)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 311, in wait
    fs = {ensure_future(f, loop=loop) for f in set(fs)}
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 311, in <setcomp>
    fs = {ensure_future(f, loop=loop) for f in set(fs)}
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 514, in ensure_future
    raise ValueError('loop argument must agree with Future')
ValueError: loop argument must agree with Future

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 127, in _run
    self._callback(*self._args)
  File "/home/dpineda/Proyectos/TaskTools/tasktools/taskloop.py", line 40, in renew_quamash
    raise task.result()
  File "/home/dpineda/Proyectos/TaskTools/tasktools/taskloop.py", line 11, in coromask
    obtained=await coro(*args)
  File "/home/dpineda/Proyectos/DragonCharts/dragoncharts/qtgui/interface.py", line 382, in updates
    await self.read_stations_queue()
  File "/home/dpineda/Proyectos/DragonCharts/dragoncharts/qtgui/interface.py", line 257, in read_stations_queue
    conn=await self.connect_rethinkdb()
  File "/home/dpineda/Proyectos/DragonCharts/dragoncharts/qtgui/interface.py", line 315, in connect_rethinkdb
    conn=await r.async_connect()
  File "/home/dpineda/Proyectos/NetworkTools/networktools/dbs/rethinkdb.py", line 43, in async_connect
    **kwargs)
  File "/home/dpineda/.virtualenvs/dragoncharts/lib/python3.6/site-packages/rethinkdb/asyncio_net/net_asyncio.py", line 293, in reconnect
    return (yield from self._instance.connect(timeout))
  File "/home/dpineda/.virtualenvs/dragoncharts/lib/python3.6/site-packages/rethinkdb/asyncio_net/net_asyncio.py", line 156, in connect
    (self._parent.host, self._parent.port, str(err)))
rethinkdb.errors.ReqlDriverError: Could not connect to atlas.csn.uchile.cl:28015. Error: loop argument must agree with Future

So, it's look like the quamash loop has some incompatibilities with some Future on the 'ensure_future' methods.

I hope that could has some solution and be useful to develop your module.

If you need some more, i'm here to help

Best regards!

@dpineiden
Copy link
Author

I checked more the source code and...
The quamash loop has not 'create_connection' method, that is called after asyncio.open_connection is executed.
So maybe that is the origin of the error. The functionalitiy isn't implemented yet

@harvimt
Copy link
Owner

harvimt commented Jan 20, 2018

So you have 2 event loops (one quamash and one rethinkdb)? That's going to cause issues if you try to share futures between 2 different loops.

@harvimt
Copy link
Owner

harvimt commented Jan 20, 2018

Can you share a minimal executable code snippet to reproduce the behavior?

@dpineiden
Copy link
Author

dpineiden commented Jan 22, 2018

Hello.

RethinkDB can run over ant asyncio loop, given a 'loop' by keyword it select and runs the connection over that 'loop'.
I'm running a multiprocessing system in what a process runs with the quamash loop and uses rethinkdb to connect and obtain data.
You can use and check that with my repo:

DragonCharts
https://gitlab.com/pineiden/dragoncharts/tree/queuecontrol

File to create RethinkDB instance:
https://gitlab.com/pineiden/dragoncharts/blob/queuecontrol/dragoncharts/qtgui/interface.py
Lines 203 ..

Needs:

TaskTools
This module allows and independent loop for coroutines inside the event loop

https://gitlab.com/pineiden/tasktools

NetworkTools
This module provide a lot of functions or classes that are useful

https://gitlab.com/pineiden/networktools

RethinkDB

pip install rethinkdb

Some RethinkDB implementation tests
https://gitlab.com/pineiden/rethink_tests

ChartsModule
Plots many traces of gnss
http://www.mediafire.com/file/ugq5ylob9v2d3ow/gnss_traces.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants