[Tutor] demon / app I/F better way ?

Dave S pythontut at pusspaws.net
Sun Nov 14 17:41:30 CET 2004


Kent Johnson wrote:

> Dave S wrote:
>
>> Running the demon as a seperate thread is a good idea, I had not 
>> thought of that, I was going to 'demon.py &' it - which must be 
>> pretty inefficient.
>>
>> Queueing the data, like a FIFO buffer, that negates the need for  
>> /data/data_flag, if its read, its gone - thats elegent -  I like that 
>> :-) . I could write a script that implements a FIFO function - or 
>> maybe I will find one in the vaults.
>
>
> See the Queue module in the standard library
>
>> As to using a socket, I have only encounterd passing references to 
>> them mainly when tweeking the linux kernel , Can you point me in the 
>> direction of how you can use them in Python ... ?
>
>
> See the socket module to start, or the socket programming HOW-TO: 
> http://www.amk.ca/python/howto/sockets/
>
> There are others on this list with more experience than me with socket 
> programming, I hope they will chime in here...personally I like 
> threads :-)
>
> Kent 


...mmm ... Now I have an idea as to what sockets are, I like threads to 
:-), they seem OTT for what I need.

Having decided on threading the demon, and using a fifo, the queue 
module looks cool, I have one last dilema. One that quite often causes 
me problems, that scope, namespace thing ;-)

If I have my demon thread running, and I define a queue, it will work 
fine, If I have my main app running and define a queue, it will also 
work fine but this defines two seperate queues which are not joined, 
data from one will not pass to the other.

If I were to define a seperate script which handles the queue 
'fifio.py'  & import it to both the deamon thread & the main app, this 
would use the class definition as a king of global variable. Would this 
be the best way ? - more importantly would it work :-D !

Dave













More information about the Tutor mailing list