Is automatic reclamation of the session in the event of your perl script abnormally exiting an issue? I.e. if the script using the session dies, do you want the session automatically released?

If so, consider keeping track of the used sessions with locks on some OS resource - like a file. When the process holding the lock exits, the lock will automatically be released. Otherwise this is very similar to the database approach except that you would query the status of the sessions via the OS with commands like fuser and lsof instead of using SQL.

Another possibility is to use the advisory locking feature provided for by mysql. It allows you to 'lock' an arbitrary string, and the lock will be released when the database connection is closed.

I would first explore solutions where you don't have to write your own daemon. This will mean that mean that you'll be putting the session acquisition code in your perl scripts, and scripts which are waiting to run will have to periodically poll the pool of sessions for a free session, but it's easy to implement, and it might work well enough.


In reply to Re: Ressource dispatcher by pc88mxer
in thread Ressource dispatcher by jeepj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.