gevent, sockets and syncronisation
Posted
by
schlamar
on Stack Overflow
See other posts from Stack Overflow
or by schlamar
Published on 2012-12-07T08:39:05Z
Indexed on
2012/12/08
11:07 UTC
Read the original article
Hit count: 226
I have multiple greenlets sending on a common socket. Is it guaranteed that each package sent via socket.sendall is well separated or do I have to acquire a lock before each call to sendall.
So I want to prevent the following scenario:
- g1 sends
ABCD - g2 sends
1234 - received data is mixed up, for example
AB1234CD - expected is either
ABCD1234or1234ABCD
Update
After a look at the sourcecode I think this scenario cannot happen. But I have to use a lock because g1 or g2 can crash on the sendall. Can someone confirm this?
© Stack Overflow or respective owner