Re: Saving application state

Celso Barriga <[email protected]> Thu, 13 Feb 2014 13:52:36 -0500
Newsgroups gmane.comp.lang.perl.poe
Message-ID <CAEijLJng2bc99mj3A0V-PSm0qKV0KbcHZE35Y9Akjge+Gsg_8g@mail.gmail.com>
--001a113a359c57f88a04f24e31ef
Content-Type: text/plain; charset=ISO-8859-1

Thanks guys.

I think I'll go with Rocco's suggestion. Since I'll be reading and writing
probably only 7 to 10 characters, should be no worries about call being
blocked. Besides, I probably want the previous data already in the file
before the next iteration, now that I think about it. And I also like your
suggestion about using File::AtomicWrite.


On Thu, Feb 13, 2014 at 1:37 PM, Rocco Caputo <[email protected]> wrote:

> Hi, Celso.
>
> This isn't a job for POE.
>
> Use File::AtomicWrite, or something like it, to safely write the time
> stamp as frequently as necessary.  It's a trivial amount of data, so you
> probably don't need it written asynchronously.
>
> Reload the time stamp when the program restarts.
>
> --
> Rocco Caputo <[email protected]>
>
> On Feb 13, 2014, at 13:21, Celso Barriga <[email protected]> wrote:
>
> > Hello, it's me again :)
> >
> > I have a POE-based application that queries a web app for some data
> filtered on some time range, say, "send me any changes from time x to now".
> >
> > The application will be running 24/7, and will query for more changes
> since the last time it asked for changes. I have a tick handler that keeps
> the heartbeat going every second so I can do the query repeatedly.
> >
> > I need to save the last time it made the query in some persistent
> fashion so I can pass it in my next query. I can't just save it to my heap
> in case the application quits, I need to be able to resume the query since
> the last successful query.
> >
> > What is the best way of doing this, the "POE way". Can I just save it to
> a file and read it back every tick count, which is 1 sec, using a regular
> file handle?
> >
> > Thanks in advance!
> >
> > Celso
> >
> >
>
>

--001a113a359c57f88a04f24e31ef
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks guys.<div><br></div><div>I think I&#39;ll go with R=
occo&#39;s suggestion. Since I&#39;ll be reading and writing probably only =
7 to 10 characters, should be no worries about call being blocked. Besides,=
 I probably want the previous data already in the file before the next iter=
ation, now that I think about it. And I also like your suggestion about usi=
ng File::AtomicWrite.</div>
</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Thu,=
 Feb 13, 2014 at 1:37 PM, Rocco Caputo <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:[email protected]" target=3D"_blank">[email protected]</a>&gt;</span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Hi, Celso.<br>
<br>
This isn&#39;t a job for POE.<br>
<br>
Use File::AtomicWrite, or something like it, to safely write the time stamp=
 as frequently as necessary. =A0It&#39;s a trivial amount of data, so you p=
robably don&#39;t need it written asynchronously.<br>
<br>
Reload the time stamp when the program restarts.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Rocco Caputo &lt;<a href=3D"mailto:[email protected]">[email protected]</a>=
&gt;<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
On Feb 13, 2014, at 13:21, Celso Barriga &lt;<a href=3D"mailto:cbarriga@gma=
il.com">[email protected]</a>&gt; wrote:<br>
<br>
&gt; Hello, it&#39;s me again :)<br>
&gt;<br>
&gt; I have a POE-based application that queries a web app for some data fi=
ltered on some time range, say, &quot;send me any changes from time x to no=
w&quot;.<br>
&gt;<br>
&gt; The application will be running 24/7, and will query for more changes =
since the last time it asked for changes. I have a tick handler that keeps =
the heartbeat going every second so I can do the query repeatedly.<br>

&gt;<br>
&gt; I need to save the last time it made the query in some persistent fash=
ion so I can pass it in my next query. I can&#39;t just save it to my heap =
in case the application quits, I need to be able to resume the query since =
the last successful query.<br>

&gt;<br>
&gt; What is the best way of doing this, the &quot;POE way&quot;. Can I jus=
t save it to a file and read it back every tick count, which is 1 sec, usin=
g a regular file handle?<br>
&gt;<br>
&gt; Thanks in advance!<br>
&gt;<br>
&gt; Celso<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>

--001a113a359c57f88a04f24e31ef--