On Sat, Sep 26, 2009 at 7:00 AM,
<pyrex-request@lists.copyleft.no> wrote:
while 1:
Py_BEGIN_ALLOW_THREADS
n = pcap_ex_next(self.__pcap, &hdr, &pkt)
Py_END_ALLOW_THREADS
self._hdr = hdr
self._pkt = pkt
if n == 1:
return (hdr.ts.tv_sec + (hdr.ts.tv_usec / 1000000.0),
PyBuffer_FromMemory(pkt, hdr.caplen))
elif n == -1:
raise KeyboardInterrupt
elif n == -2:
raise StopIteration
the problem is with a timeout. basically it doesn't work. it waits
till a packet arrive.
Doesn't that code need an 'if n == 0: break' (or similar) ?
Otherwise it will retake the GIL when the timeout happens, and immediately release it again and wait for a second timeout period, and third... and so on. See, the while 1.