Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what I'd do (I'm actually considering writing this library after seeing your question. I need it too):</p> <p>Create a <code>taskpool</code> module with the following API.</p> <pre><code>client_id, token = taskpool.get() # Setup a heartbeat in the client JS, maybe every minute. # Also call this every time the client indicates presence taskpool.ping(client_id) taskpool.release(client_id) </code></pre> <p>Implementation: </p> <ul> <li>Store the <code>client_id</code> and <code>token</code> in an entity, with a status indicating whether it's being used, last ping time, and creation time. Let the <code>client_id</code> be the key. Also consider using <a href="http://code.google.com/p/appengine-ndb-experiment/" rel="noreferrer">NDB</a>. Free memcaching. </li> </ul> <p><code>get()</code> checks if there are unused tokens and returns one if it finds it. Otherwise create a new one, store and return it. </p> <p><code>ping()</code> updates the last ping time for that token. Instead of polling, let the client send in a ping every [heartbeat] time. </p> <p><code>release()</code> marks the token as unused. </p> <p>Run a task / cron every [heartbeat] seconds to find the tokens which haven't gotten a ping in a while - and set them as unused. </p> <p>When clients report a closed token, perform a <code>get()</code>.</p> <p>Keep in mind, though, that a loss in security is a by-product of any kind of token pooling. If a malicious client has held on to a token and stopped sending heartbeats, it might later be able to listen in on the messages being passed to the new client once the token is re-purposed. This isn't a problem if you're on a fully public site, but keep it in mind anyway.</p> <p>I will update this answer if and when I write this up as a library. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload