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

Triopg crashes on windows due to "TypeError: need a stdlib socket" #31

Closed
touilleMan opened this issue Aug 16, 2018 · 4 comments
Closed

Comments

@touilleMan
Copy link
Member

TrioPG (trio wrapper of asyncpg based on trio-asyncio) is crashing on windows:

fut = <Task cancelled coro=<BaseEventLoop.create_connection() done, defined at C:\Python36-x64\lib\asyncio\base_events.py:681>>
timeout = 60
    @coroutine
    def wait_for(fut, timeout, *, loop=None):
        """Wait for the single Future or coroutine to complete, with timeout.
    
        Coroutine will be wrapped in Task.
    
        Returns result of the Future or coroutine.  When a timeout occurs,
        it cancels the task and raises TimeoutError.  To avoid the task
        cancellation, wrap it in shield().
    
        If the wait is cancelled, the task is also cancelled.
    
        This function is a coroutine.
        """
        if loop is None:
            loop = events.get_event_loop()
    
        if timeout is None:
            return (yield from fut)
    
        waiter = loop.create_future()
        timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
        cb = functools.partial(_release_waiter, waiter)
    
        fut = ensure_future(fut, loop=loop)
        fut.add_done_callback(cb)
    
        try:
            # wait until the future completes or the timeout
            try:
                yield from waiter
            except futures.CancelledError:
                fut.remove_done_callback(cb)
                fut.cancel()
                raise
    
            if fut.done():
                return fut.result()
            else:
                fut.remove_done_callback(cb)
                fut.cancel()
>               raise futures.TimeoutError()
E               concurrent.futures._base.TimeoutError
C:\Python36-x64\lib\asyncio\tasks.py:362: TimeoutError
------------------------------ Captured log call ------------------------------
base_events.py            1299 ERROR    Exception in default exception handler
Traceback (most recent call last):
  File "C:\Python36-x64\lib\asyncio\base_events.py", line 1293, in call_exception_handler
    self.default_exception_handler(context)
  File "C:\Python36-x64\lib\site-packages\trio_asyncio\async_.py", line 50, in default_exception_handler
    raise exception
  File "C:\Python36-x64\lib\site-packages\trio_asyncio\base.py", line 600, in _writer_loop
    await _wait_writable(fd)
  File "C:\Python36-x64\lib\site-packages\trio\_core\_io_windows.py", line 371, in wait_socket_writable
    await self._wait_socket("write", sock)
  File "C:\Python36-x64\lib\site-packages\trio\_core\_io_windows.py", line 350, in _wait_socket
    raise TypeError("need a stdlib socket")
TypeError: need a stdlib socket

see full CI logs here: https://ci.appveyor.com/project/touilleMan/triopg/build/job/mi2fi495cgvurjb8#L533

Error is the same than reported in #22

@njsmith
Copy link
Member

njsmith commented Aug 17, 2018

I suspect the fix is python-trio/trio#400 (i.e., fixing trio.hazmat.wait_socket_{read,writ}able so that they accept bare socket fds)

@njsmith
Copy link
Member

njsmith commented Aug 21, 2018

python-trio/trio#400 is now fixed in trio master, so hopefully this is fixed if you're using the latest trio from git? If you have a chance to check then it'd be nice to know :-)

@touilleMan
Copy link
Member Author

@njsmith I'll wait for trio 0.7.0 to be released to restart this test (given I don't have windows dev environment, it's much simpler to just re-use the failing appveyor build which will install the lastest trio on pypi)

@touilleMan
Copy link
Member Author

@njsmith It is fixed now 😄 (cf. https://travis-ci.org/python-trio/triopg/builds/436782294)

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