Ok, so after cheking newcron.py I can see the main issue here is that
cron tasks are run in a totally independent process, via subprocess
module, so it's impossible to use threading shared data.

Has rocket a maximum request timeout? If not, I could use cron @reboot
to launch a request to a special URL where a infinite duration task is
started, so I could use that thread to do the sensor polling and share
data with the other threads using cache.ram, or in-memory sqlite
databases.

I'll give a try to that approach, any suggestions are appreciated.

Thanks very much.

On 22 sep, 08:04, Álvaro J. Iradier <[email protected]> wrote:
> Thanks Massimo,
>
> I forgot to mention I'm using the integrated rocket web server (not
> mod_python, cgi or whatever). So I was just curious if there was a way
> of sharing data between the hard "cron" thread and the thread where
> the requests are run, without needing to serialize informate (picke-
> unpickle or anything). I also thought of using a socket, instead of
> named pipes.
>
> Basically, I want to avoid database writing because the application is
> run from a SD card, to avoid wearing.
>
> However, if there exists not a way for sharing class instances or
> plain variables between cron and request threads, I'm going to take a
> look at using a database from RAM or from a tmpfs.
>
> I was thinking of using ":memory:" in-memory sqlite database, but I
> would hit the same problem: I can't share the "db_in_memory" from the
> cron thread to the request thread.
>
> Thanks very much.
>
> On 21 sep, 22:28, mdipierro <[email protected]> wrote:
>
>
>
> > If not and you have a single web2py installation you can use a named
> > pipe
>
> >http://stackoverflow.com/questions/1430446/create-a-temporary-fifo-na...
>
> > has pros and cons. data can be lost or corrupted if the reading/
> > writing app crashes.
> > I would use the database because of transcaction safety.
>
> > Massimo
>
> > On Sep 21, 3:21 pm, Álvaro J. Iradier <[email protected]> wrote:
>
> > > Hi,
>
> > > I've setup a background worker thread using cron @reboot. The
> > > background worker is polling some serial sensors all the time (there's
> > > a loop in class reading the sensor values). On some moment, the values
> > > are recorded and an alarm bit is set.
>
> > > Now, what I need is a way to share this information with a web request
> > > without writing it to the database. I've tried so far using class
> > > variables, and cache.ram, but none of them work. I think the request
> > > is being processed in a clean environment, am I right?
>
> > > So, what would be a good way of passingsome information to the request
> > > thread from the background worker class?
>
> > > Thanks very much.
>
> > > Álvaro Iradier.

Reply via email to