[gtk+thread] Why worker thread never wakes from time.sleep()?

2010-01-03 Thread Dmitry Teslenko
Hello! I have simple gui gtk app. It has worker thread that populates list with strings and gtk window with main loop which pops strings from this list and shows them in TreeView. Thread runs get_data_from_pcap to populate list with strings. Gtk app calls update_store() with gobject.timeout_add

call to pypcap in separate thread blocks other threads

2009-12-30 Thread Dmitry Teslenko
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) ...

Re: call to pypcap in separate thread blocks other threads

2009-12-30 Thread Dmitry Teslenko
On Wed, Dec 30, 2009 at 16:18, aspineux aspin...@gmail.com wrote: On Dec 30, 1:34 pm, Dmitry Teslenko dtesle...@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

Re: call to pypcap in separate thread blocks other threads

2009-12-30 Thread Dmitry Teslenko
On Wed, Dec 30, 2009 at 18:25, aspineux aspin...@gmail.com wrote: On Dec 30, 3:07 pm, Dmitry Teslenko dtesle...@gmail.com wrote: On Wed, Dec 30, 2009 at 16:18, aspineux aspin...@gmail.com wrote: On Dec 30, 1:34 pm, Dmitry Teslenko dtesle...@gmail.com wrote: Hello! I'm making gui gtk

Re: file locked for writing

2008-05-14 Thread Dmitry Teslenko
On Wed, May 14, 2008 at 8:18 AM, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 13 May 2008 11:57:03 -0300, Dmitry Teslenko [EMAIL PROTECTED] Is the code above contained in a function? So all references are released upon function exit? Yes, it's a function If not, you could try using

Re: file locked for writing

2008-05-14 Thread Dmitry Teslenko
On Wed, May 14, 2008 at 11:04 AM, Dmitry Teslenko [EMAIL PROTECTED] wrote: When I've rewrite code something like that: with open(backup_file_name, 'w') as backup_file: . filter.parse('updated file name') del input, output, filter

file locked for writing

2008-05-13 Thread Dmitry Teslenko
Hello! I use some script in python 2.5 from vim editor (it has python bindings) that updates some file and then launches another program (ms visual studio, for example) to do something with updated file. I faced problem when updated file is locked for writing until vim editor is closed. launch

pygtk + threading.Timer

2008-04-14 Thread Dmitry Teslenko
Hello! I have simple chat application with pygtk UI. I want some event (for example update user list) to have place every n seconds. What's the best way to archive it? I tried threading.Timer but result is following: all events wait till exit of gtk main loop and only then they occur. Thanks in

Re: pygtk + threading.Timer

2008-04-14 Thread Dmitry Teslenko
2008/4/14 Jarek Zgoda [EMAIL PROTECTED]: I have simple chat application with pygtk UI. I want some event (for example update user list) to have place every n seconds. What's the best way to archive it? I tried threading.Timer but result is following: all events wait till exit of gtk

draining pipes simultaneously

2008-03-05 Thread Dmitry Teslenko
Hello! Here's my implementation of a function that executes some command and drains stdout/stderr invoking other functions for every line of command output: def __execute2_drain_pipe(queue, pipe): for line in pipe: queue.put(line) return def execute2(command,

Re: draining pipes simultaneously

2008-03-05 Thread Dmitry Teslenko
On Wed, Mar 5, 2008 at 1:34 PM, [EMAIL PROTECTED] wrote: The Queue.get method by default is blocking. The documentation is not 100% clear about that (maybe it should report the full python definition of the function parameters, which makes self-evident the default value) but if you do

Re: draining pipes simultaneously

2008-03-05 Thread Dmitry Teslenko
On Wed, Mar 5, 2008 at 3:39 PM, [EMAIL PROTECTED] wrote: time.sleep() pauses ony the thread that executes it, not the others. And queue objects can hold large amount of data (if you have the RAM), so unless your subprocess is outputting data very fast, you should not have data loss.

xml-filter with XMLFilterBase() and XMLGenerator() shuffles attributes

2007-12-20 Thread Dmitry Teslenko
Hello! I've made a trivial xml filter to modify some attributes on-the-fly: ... from __future__ import with_statement import os import sys from xml import sax from xml.sax import saxutils class ReIdFilter(saxutils.XMLFilterBase): def __init__(self, upstream, downstream):

Need help with with-statement-compatible object

2007-12-19 Thread Dmitry Teslenko
Hello! I've made some class that can be used with with statement. It looks this way: class chdir_to_file( object ): ... def __enter__(self): ... def __exit__(self, type, val, tb): ... def get_chdir_to_file(file_path): return chdir_to_file(file_path) ... Snippet with

Re: Need help with with-statement-compatible object

2007-12-19 Thread Dmitry Teslenko
On Dec 19, 2007 12:14 PM, Peter Otten [EMAIL PROTECTED] wrote: def __enter__(self): # ... return self should help. That helps. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: spawn background process and detach it w/o problems

2007-11-09 Thread Dmitry Teslenko
Hello! On 08/11/2007, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Take a look at the subprocess module. Big thanks! It's interesting what's happening with subprocess.Popen instance after it has been instatiated and script's main thread exits leaving Popen'ed application open. --

[win32] spawn background process and detach it w/o problems

2007-11-08 Thread Dmitry Teslenko
Hello! How to write portable (win32, unix) script that launches another program and continues its execution? I've looked at spawn*() but it doesn't look in PATH dirs on windows so it's totally unusable when you don't know where exactly program is. I've looked at fork() way but there's no fork

Re: python 2.5 scripting in vim on windows: subprocess problem

2007-10-24 Thread Dmitry Teslenko
On 22/10/2007, Andy Kittner [EMAIL PROTECTED] wrote: Are you running this on vim or gvim? If you are running on gvim, my guess is that the handles that you are passing are not valid. In either case, try creating explicit handles that are valid (such as for /dev/null) and create the process

python 2.5 scripting in vim on windows: subprocess problem

2007-10-22 Thread Dmitry Teslenko
Hello! I'm using subprocess.Popen in python script in vim. It called this way: def some_func(): p = subprocess.Popen( command , stdout = subprocess.PIPE, stderr = subprocess.STDOUT) while True: s = p.stdout.readline()

Re: os.popen and lengthy operations

2007-09-26 Thread Dmitry Teslenko
Hello! On 24/09/2007, Tommy Nordgren [EMAIL PROTECTED] wrote: Your problem is that you are not reading the standard output and standard error streams in the correct way. You need to do the reading of standard out and standard err in parallell rather than sequentially. The called

os.popen and lengthy operations

2007-09-20 Thread Dmitry Teslenko
Hello! I'm using os.popen to perform lengthy operation such as building some project from source. It looks like this: def execute_and_save_output( command, out_file, err_file): import os def execute_and_save_output( command, out_file, err_file): (i,o,e) = os.popen3( command )