[Tutor] Problem with threading

Alberto Troiano albertito_G at hotmail.com
Wed May 4 17:18:19 CEST 2005


Hi

I took a look at the code and now I'm confused

I'll use CRON and I will make a python script that take parameters
(username) and work only for that user but the script will never finish

ÇThe FTP connection that starts the camera never ends unless I shutdown my
server. Now I'm thinking that CRON will start my script only once and I will
make a script that check for the record time of the user and insert all the
photos that are in the record time but is there a quick to insert the
filename with path to the database???? I'll have all the photos in one
directory and I want to check all directory quickly cause after it finish it
will start again and again and again and again and again and again.....i
think you get the picture

Imagine 40 users running all at the same time. I have to ask, does the
machine will overhead with this process???Does CRON make my script run as a
daemon or should I insert the daemon code you gave me:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731

What is the difference in running with CRON without the daemon code with
running with the daemon code??????

Regards

Alberto
----------------------------------------------------------------------------
-

Alberto
--------------------------------------------------------------
The one who stands beside me, does not share my pythonistic way to do things

-----Mensaje original-----
De: tutor-bounces at python.org [mailto:tutor-bounces at python.org] En nombre de
Danny Yoo
Enviado el: Martes, 03 de Mayo de 2005 03:58 a.m.
Para: Alberto Troiano
CC: Tutor; matt at mondoinfo.com
Asunto: Re: [Tutor] Problem with threading



On Tue, 3 May 2005, Alberto Troiano wrote:

> In answer to Matt the cameras push the photos via ftp at my server at 1
> photo every 3 seconds

Hi Alberto,

Just as another note: the folks here have no idea who you mean by Matt.
I do know that you mean Matt from python-help at python.org, but the folks on
Tutor now have no clue what we're talking about.  *grin*

That's sorta why it's not such a good idea to crosspost to both lists,
because now we have a conversation where not everyone can see each other.
I'll put Matt in CC, but let's try to avoid this situation next time.


> What can I do????????????

I believe that cron has a resolution of a minute, so now it doesn't sound
that cron is so viable.  But how about writing a program that just
continues to run as a "daemon" service in the background?  A simple
example is something like:

######
import time
while True:
    ## do something
    time.sleep(delay)
######

This isn't a true daemon, since it's not detached from the terminal.  But
the Python Cookbook mentions something a little more polished here:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731

and this should be a basis for writing a ftp-polling daemon.


Best of wishes to you!

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list