[Chicago] Popen/subprocess/Poll Question.
Samir Faci
samir at esamir.com
Thu Jul 22 17:57:34 CEST 2010
Inline.
On Thu, Jul 22, 2010 at 10:49 AM, Daniel Griffin <dgriff1 at gmail.com> wrote:
>
> You really don't need Threads or Processes if you just use poll. Just keep a
> list of popen's and periodically check them with poll.
>
I only spawned a thread because it seemed like communicate was
blocking, so having it on a different
thread seemed simple enough.
>
> On Thu, Jul 22, 2010 at 10:28 AM, Martin Maney <maney at two14.net> wrote:
>>
>> On Thu, Jul 22, 2010 at 09:55:24AM -0500, Samir Faci wrote:
>> > I'm running a process that's usually takes a while.... (in the best
>> > case scenario a few hours... going on days occasionally)
>> >
>> > I'm presuming I need to spawn a thread for the process so it doesn't
>> > block.
>>
>> Thread-on-the-brain disease? Why not run it as a separate process?
>> Threads are just processes that can mess each other up almost without
>> trying. :-/
>>
>> > Now, what I'm trying to accomplish is to have it print its output to a
>> > screen AND let me capture its output. I'd like to see the output.
>> > I'd also like to see the output as its processing, not capture it, and
>> > print it to screen and then write to file.
>>
>> There's an Anciente Unixe command that does this very thing, named
>> "tee". Just sayin'
sure. tee would work. But I have a nice logger library that adds
those handy timestamps.. which helps me figure out when things broke
etc.
and see if it hasn't printed anything for 3 hours.. that I can
probably kill it because it's hung.
I wanted to handle the output of the program internally in my python
code. I've use tee before, but it's not as versatile as I'd like it
to be.
--
Samir
>>
>> --
>> I'm not proud. We really haven't done everything we could to
>> protect our customers ... Our products just aren't engineered
>> for security. -- Brian Valentine, Microsoft Senior VP
>> in charge of the Windows development team
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> http://mail.python.org/mailman/listinfo/chicago
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
--
--
Samir Faci
*insert title*
fortune | cowsay -f /usr/share/cows/tux.cow
More information about the Chicago
mailing list