Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe11d3e

Browse files
committed
Adds support for the DBEnv->set_timeout() method.
1 parent 3ae0f7a commit fe11d3e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lib/bsddb/test/test_lock.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ def test02_threaded(self):
9797
for t in threads:
9898
t.join()
9999

100-
100+
def test03_set_timeout(self):
101+
# test that the set_timeout call works
102+
if hasattr(self.env, 'set_timeout'):
103+
self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
104+
self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
105+
self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
106+
self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
101107

102108
def theThread(self, sleepTime, lockType):
103109
name = currentThread().getName()

Modules/_bsddb.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,6 +3163,29 @@ DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
31633163
}
31643164
#endif /* DBVER >= 41 */
31653165

3166+
#if (DBVER >= 40)
3167+
static PyObject*
3168+
DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
3169+
{
3170+
int err;
3171+
u_int32_t flags=0;
3172+
u_int32_t timeout = 0;
3173+
char* kwnames[] = { "timeout", "flags", NULL };
3174+
3175+
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
3176+
&timeout, &flags)) {
3177+
return NULL;
3178+
}
3179+
3180+
MYDB_BEGIN_ALLOW_THREADS;
3181+
err = self->db_env->set_timeout(self->db_env, (db_timeout_t)timeout, flags);
3182+
MYDB_END_ALLOW_THREADS;
3183+
3184+
RETURN_IF_ERR();
3185+
RETURN_NONE();
3186+
}
3187+
#endif /* DBVER >= 40 */
3188+
31663189
static PyObject*
31673190
DBEnv_set_cachesize(DBEnvObject* self, PyObject* args)
31683191
{
@@ -3955,6 +3978,9 @@ static PyMethodDef DBEnv_methods[] = {
39553978
{"dbremove", (PyCFunction)DBEnv_dbremove, METH_VARARGS|METH_KEYWORDS},
39563979
{"dbrename", (PyCFunction)DBEnv_dbrename, METH_VARARGS|METH_KEYWORDS},
39573980
{"set_encrypt", (PyCFunction)DBEnv_set_encrypt, METH_VARARGS|METH_KEYWORDS},
3981+
#endif
3982+
#if (DBVER >= 40)
3983+
{"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS},
39583984
#endif
39593985
{"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS},
39603986
{"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS},

0 commit comments

Comments
 (0)