call to pypcap in separate thread blocks other threads

Dmitry Teslenko dteslenko at gmail.com
Wed Dec 30 11:51:55 EST 2009


On Wed, Dec 30, 2009 at 18:25, aspineux <aspineux at gmail.com> wrote:
> On Dec 30, 3:07 pm, Dmitry Teslenko <dtesle... at gmail.com> wrote:
>> On Wed, Dec 30, 2009 at 16:18, aspineux <aspin... at gmail.com> wrote:
>> > On Dec 30, 1:34 pm, Dmitry Teslenko <dtesle... at gmail.com> wrote:
>> >> Hello!
>> >> I'm making gui gtk application. I'm using pypcap
>> >> (http://code.google.com/p/pypcap/) to sniff some network packets.
>> >> To avoid gui freezing I put pcap call to another thread.
>> >> Pypcap call looks like:
>>
>> >> pc = pcap.pcap()
>> >> pc.setfilter('tcp')
>> >> for ts, pkt in pc:
>> >>         spkt = str(pkt)
>> >>         ...
>>
>> >> Sadly, but this call in another thread blocks gtk gui thread anyway.
>> >> If I substitute pcap call with something else separate thread don't block
>> >> gui thread.
>>
>> >> Using another process instead of thead isn't appropriate.
>>
>> >> Thread initialization looks like and takes place before gtk.main():
>>
>> >> self.__pcap_thread = threading.Thread(target = self.get_city_from_pcap)
>> >> self.__pcap_thread.start()
>>
>> > Did you try using build-in gtk thread ?
>>
>> > Regards
>>
>> > Alain Spineux                         |  aspineux gmail com
>> > Your email 100% available             |  http://www.emailgency.com
>> > NTBackup frontend sending mail report |  http://www.magikmon.com/mkbackup
>>
>> >> --
>> >> A: Because it messes up the order in which people normally read text.
>> >> Q: Why is top-posting such a bad thing?
>> >> A: Top-posting.
>> >> Q: What is the most annoying thing in e-mail?
>> > --
>> >http://mail.python.org/mailman/listinfo/python-list
>>
>> No. What makes it different?
>
> It allow you to access to you GTK widgets from your threads (you have
> rules to follow to do that).
>
> What are you doing from inside your "pcap" thread ?
>
>
>
>>
>> --
>> A: Because it messes up the order in which people normally read text.
>> Q: Why is top-posting such a bad thing?
>> A: Top-posting.
>> Q: What is the most annoying thing in e-mail?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I do this thing:

>> >> pc = pcap.pcap()
>> >> pc.setfilter('tcp')
>> >> for ts, pkt in pc:
>> >>         spkt = str(pkt)
>> >>         ...

pc.next() blocks other threads. I visit project page and ppl mention
similar issues. Now I think it's pypcap-related problem and project
page is right place to discuss this issue.
Thanks for support.

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?



More information about the Python-list mailing list