No buffer available on Windows platform
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
Do you have a pyuv-only test case which exhibits the problem? Without that or a traceback there is little I can do :-S
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. (https://github.com/saghul/pyuv/blob/94d34d6522bf079577427f93e2e107be905dd9f2/src/common.c#L267)
@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.
What happens if you ignore pyuv.errno.UV_ENOBUFS on the read callback? Does it continue working properly?
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.
Hum, that's weird. I'll take a look on a Windows machine as soon as I can.
@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?