3. Object-oriented wrapper

class doloop.DoLoop(dbconn, table)

A very thin wrapper that stores connection and table name, so you don’t have have to specify dbconn and table over and over again.

For example:

foo_loop = doloop.DoLoop(dbconn, 'foo_loop')

foo_ids = foo_loop.get(100)

for foo_id in foo_ids:
    # update foo_id
    ...

foo_loop.did(foo_ids)
DoLoop.__init__(dbconn, table)

Wrap a task loop table in an object

Parameters:
  • dbconn – any DBI-compliant MySQL connection object, or a callable that returns one. If you use a callable, it’ll be called every time a method is called on this object, so put any caching/pooling/etc. inside your callable.
  • table (string) – name of your task loop table

You can read (but not change) the table name from self.table

DoLoop.add(id_or_ids, updated=False, test=False)

Add IDs to this task loop.

See add() for details.

DoLoop.remove(id_or_ids, updated=False, test=False)

Remove IDs from this task loop.

See remove() for details.

DoLoop.get(limit, lock_for=3600, min_loop_time=3600, test=False)

Get some IDs of things to update and lock them.

See get() for details.

DoLoop.did(id_or_ids, auto_add=True, test=False)

Mark IDs as updated and unlock them.

See did() for details.

DoLoop.unlock(id_or_ids, auto_add=True, test=False)

Unlock IDs without marking them updated.

See unlock() for details.

DoLoop.bump(id_or_ids, lock_for=0, auto_add=True, test=False)

Bump priority of IDs.

See bump() for details.

DoLoop.check(id_or_ids)

Check the status of particular IDs.

See check() for details.

DoLoop.stats()

Check on the performance of the task loop as a whole.

See stats() for details.