Here is my server
\"\"\"Server using epoll method\"\"\"
import os
import select
import socket
import time
from oodict import OODict
addr = (\
My ad-hoc solution to bypass this problem
--- epoll_demo.py.orig 2009-04-28 18:11:32.000000000 +0800
+++ epoll_demo.py 2009-04-28 18:12:56.000000000 +0800
@@ -18,6 +18,7 @@
epoll.register(s.fileno(), select.EPOLLIN) # Level triggerred
cs = {}
+en = {}
data = ''
while True:
time.sleep(1)
@@ -29,10 +30,18 @@
sk.setblocking(0)
print addr
cs[sk.fileno()] = sk
+ en[sk.fileno()] = 0
epoll.register(sk.fileno(), select.EPOLLIN)
elif event & select.EPOLLIN:
data = cs[fileno].recv(4)
+ if not data:
+ en[fileno] += 1
+ if en[fileno] >= 3:
+ print 'closed'
+ epoll.unregister(fileno)
+ continue
+ en[fileno] = 0
print 'recv ', data
epoll.modify(fileno, select.EPOLLOUT)
elif event & select.EPOLLOUT: