Weird problem with UDP and gevent
James Harris
james.harris.1 at gmail.com
Fri Oct 18 13:04:38 EDT 2013
"Roy Smith" <roy at panix.com> wrote in message
news:l3riea$82$1 at panix2.panix.com...
> I'm running:
>
> Ubuntu Precise
> Python 2.7.3
> django 1.4.5
> gunicorn 0.17.4
> gevent 1.0dev (rc3)
>
> I haven't been able to pin this down exactly, but it looks like if I
> do (inside of a custom logging.Handler subclass):
>
> # Paraphrased from the actual code
> remote_addr = ("localhost", 9700)
> self.socket = socket.socket(type=socket.SOCK_DGRAM)
> payload = "..."
> self.socket.connect(remote_addr)
> self.socket.send(payload)
>
> I get intermittant hangs in the connect() call. If I rewrite this as:
>
> remote_addr = ("localhost", 9700)
> self.socket = socket.socket(type=socket.SOCK_DGRAM)
> payload = "..."
> self.socket.sendto(payload, remote_addr)
>
> everything works fine. Has anybody seen anything like this? I'm
> guessing this is some kind of gevent bug.
Those are two different things. You would normally use connect() on a
SOCK_STREAM socket. It requires that the remote endpoint, in this case
localhost:9700, has an open socket listening for connections. sendto() is
the right thing to use with SOCK_DGRAM.
James
More information about the Python-list
mailing list