Skip to content

Commit

Permalink
Adds support for the DBEnv->set_timeout() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gpshead committed Mar 27, 2003
1 parent 3ae0f7a commit fe11d3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Lib/bsddb/test/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ def test02_threaded(self):
for t in threads:
t.join()


def test03_set_timeout(self):
# test that the set_timeout call works
if hasattr(self.env, 'set_timeout'):
self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)

def theThread(self, sleepTime, lockType):
name = currentThread().getName()
Expand Down
26 changes: 26 additions & 0 deletions Modules/_bsddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3163,6 +3163,29 @@ DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
}
#endif /* DBVER >= 41 */

#if (DBVER >= 40)
static PyObject*
DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
{
int err;
u_int32_t flags=0;
u_int32_t timeout = 0;
char* kwnames[] = { "timeout", "flags", NULL };

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
&timeout, &flags)) {
return NULL;
}

MYDB_BEGIN_ALLOW_THREADS;
err = self->db_env->set_timeout(self->db_env, (db_timeout_t)timeout, flags);
MYDB_END_ALLOW_THREADS;

RETURN_IF_ERR();
RETURN_NONE();
}
#endif /* DBVER >= 40 */

static PyObject*
DBEnv_set_cachesize(DBEnvObject* self, PyObject* args)
{
Expand Down Expand Up @@ -3955,6 +3978,9 @@ static PyMethodDef DBEnv_methods[] = {
{"dbremove", (PyCFunction)DBEnv_dbremove, METH_VARARGS|METH_KEYWORDS},
{"dbrename", (PyCFunction)DBEnv_dbrename, METH_VARARGS|METH_KEYWORDS},
{"set_encrypt", (PyCFunction)DBEnv_set_encrypt, METH_VARARGS|METH_KEYWORDS},
#endif
#if (DBVER >= 40)
{"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS},
#endif
{"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS},
{"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS},
Expand Down

0 comments on commit fe11d3e

Please sign in to comment.