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

No buffer available on Windows platform #211

Open
vit1251 opened this issue Jan 5, 2016 · 7 comments
Open

No buffer available on Windows platform #211

vit1251 opened this issue Jan 5, 2016 · 7 comments

Comments

@vit1251
Copy link

vit1251 commented Jan 5, 2016

Minimal crash code:

#!/usr/bin/python

import sys

import pyuv

##
## Default loop
##

loop = pyuv.Loop.default_loop()


##
## Create TCP connection
##

# One of FreeNODE IRC Server Host
ip, port = '62.231.75.133', 6666

def read_cb(tcp_handle, data, errno):
    print("Socket read (errno = {errno!r})".format(errno=errno))
    print data

def connect_cb(tcp_handle, errno):
    print("Connect (errno = {errno!r})".format(errno=errno))
    tcp_handle.start_read(read_cb)

tcp = pyuv.TCP(loop)
tcp.connect((ip, port), connect_cb)

##
## Using TTY interaction
##

def terminal_read_cb(*args):
    print("Terminal read")
    print args

tty = pyuv.TTY(loop, sys.stdin.fileno(), True)
tty.start_read(terminal_read_cb)


##
## Main point
##

loop.run()

On Windows platform it cause a

Connect (errno = None)
Socket read (errno = -4060)
None
Terminal read
Unhandled exception in callback
@saghul
Copy link
Owner

saghul commented Jan 5, 2016

Do you have a pyuv-only test case which exhibits the problem? Without that or a traceback there is little I can do :-S

@moteus
Copy link

moteus commented Jan 5, 2016

I am not sure but I saw somewhere that on Windows libuv may need more then one buffer at same time.
I think this number is equal to number of threads that uses by iocp.
But pyuv uses only one buffer all the time. (

pyuv__alloc_cb(uv_handle_t* handle, size_t suggested_size, uv_buf_t *buf)
)

@saghul
Copy link
Owner

saghul commented Jan 5, 2016

@moteus libuv uses a single thread (per loop) for IOCP. Within a loop operations will always be like alloc -> read, alloc -> read, so using a single buffer per loop is safe as far as I'm concerned.

@saghul
Copy link
Owner

saghul commented Jan 6, 2016

What happens if you ignore pyuv.errno.UV_ENOBUFS on the read callback? Does it continue working properly?

@vit1251
Copy link
Author

vit1251 commented Jan 6, 2016

What happens if you ignore pyuv.errno.UV_ENOBUFS on the read callback?

If it mean just ignore this error (does not raise and handle this problem) then as you can see simple source code may continue but it look like it freeze.

What do you mean say "if you ignore pyuv.errno.UV_ENOBUFS on the read callback"? I was not invoke additional function for ignore this error or doing hidden setup somewhere. You see full source code there.

Does it continue working properly?

No. No more socket read callback. But TTY was working.
I redesign code and try start socket after tty initialize and also have buffer error.

@saghul
Copy link
Owner

saghul commented Jan 6, 2016

Hum, that's weird. I'll take a look on a Windows machine as soon as I can.

@schlamar
Copy link
Collaborator

@vit1251 Is this issue still present on pyuv 1.3.0? If yes, please provide a test case which is not requiring internet access. I modified your script above connecting to a local TCP server and cannot reproduce this issue. Which Python version are you using?

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

4 participants