On 31May2019 19:41, nathan tech <nathan-t...@hotmail.com> wrote:
Is it possible, in python, to store a running task id in the registry?

I might be using the complete wrong terms here, because I'm only used to
doing this with a specific language, but here's what I want to do:

python mytest.py:
 print 'already open'
 send to open program to make a ding noise.

I understand that the second part, the "send to program" requires the
program to handle being sent a "wake up!" event, which is fine, it's the
"is it already running" which I am not sure on.

Well, you need to have some kind of persistent storage of tasks and a way to check if some described task is running. I don't know what constitutes a task in your mind here, or what you consider "the registry".

There is any number of ways to store persistent values.

A simple one is a CSV file: keep one around with a line per task including the taskid and whatever other relevant information is needed. Reread the file when needed. To avoid difficulties with updating an arbitrary record in such a file (which is just a text file with lines of variying lengths) you could treat it like a log: just append more lines containing the new task state. On reading the file, just keep the last line per task.

Less simple, but more flexible, might be some kind of database. Python ships with SQLite3 support, which lets you have a little SQL database in a local file.

It is hard to be any more specific without knowing what you consider a task, and how you'd check if it was active.

Cameron Simpson <c...@cskk.id.au>
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to