Commit Graph

34 Commits

Author SHA1 Message Date
behackett
1fe6029c5d Fix replica set monitor issues PYTHON-365.
Note: In CPython the monitor is no longer a daemon thread. This means that
care must be taken in the interactive shell and simple scripts to set
ReplicaSetConnection references to None so the monitor dies.

The monitor is still a daemon thread in Jython and PyPy.
2012-07-03 12:56:01 -07:00
A. Jesse Jiryu Davis
f2cd5c6f2b Slightly refactor threading tests 2012-04-29 21:34:05 -04:00
A. Jesse Jiryu Davis
326b710382 More reliable multithread tests on slow machines 2012-04-23 15:23:20 -04:00
A. Jesse Jiryu Davis
839d3af512 Daemonize threads used in tests so failed test won't hang process 2012-04-21 07:13:06 -06:00
behackett
0ee7170cc2 It's 2012... 2012-04-19 12:40:38 -07:00
A. Jesse Jiryu Davis
c4dd702143 Fix up tests for Python pre-2.7 PYTHON-345 2012-04-17 22:05:05 -04:00
A. Jesse Jiryu Davis
1def725f4a PYTHON-345 don't reuse request sockets after the pool is reset 2012-04-16 16:53:38 -04:00
behackett
12592be1fe Python 3 unittest changes PYTHON-84. 2012-03-28 11:53:47 -07:00
A. Jesse Jiryu Davis
62e0c23d67 Don't drop databases unnecessarily during tests, saves about 35% of unittest time PYTHON-320 2012-03-19 12:16:33 -04:00
A. Jesse Jiryu Davis
34538c155e Make auto_start_request optional (default True), add ReplicaSetConnection.start_request, return sockets to pool when threads die PYTHON-287
Big change to PyMongo connection pooling:

* While we still allocate a socket per thread by default, this is now optional. It is also possible to share sockets among threads, safely, and thus using fewer total sockets, by creating a Connection or ReplicaSetConnection with auto_start_request=False.

* In the past, when a thread died without calling end_request() its socket was closed. We now reclaim such sockets for the pool, which should reduce connection churn.

* start_request() now returns a context manager so you can do "with connection.start_request():"

* ReplicaSetConnection now supports start_request, although its semantics aren't consistent for ReadPreferences other than PRIMARY

* Refactoring: Connection and ReplicaSetConnection had different pool implementations, now they share one.
2012-03-14 17:12:11 -04:00
A. Jesse Jiryu Davis
95974a2595 Broken imports, better commentary on skipped test 2012-02-08 18:21:26 -08:00
A. Jesse Jiryu Davis
9a05f49e2c Check more reliably if server has auth enabled before running authentication tests 2012-02-08 18:21:26 -08:00
A. Jesse Jiryu Davis
902d55bcfa Bugfix (again) my multithreaded ReplicaSetConnection tests -- prevent Nose from running tests in test_threads twice. 2011-12-05 23:08:37 -05:00
A. Jesse Jiryu Davis
e0fc2e0f15 Apply multithreading unittests to new ReplicaSetConnection class. 2011-12-05 18:24:32 -05:00
behackett
fcb7ffb25f Auth improvements w/pooling and threads PYTHON-4
Also PYTHON-162 and PYTHON-189.

Credit goes to James Murty for most of the patch.

With this change we cache auth credentials (user,
password) in the driver so that each new socket
can be automatically authenticated. This solves
the problem of each new spawned thread having to
re-authenticate.
2011-07-11 19:27:20 -07:00
behackett
a0bde5a6b6 Fix a test failing with replication. 2011-06-01 21:11:02 -07:00
behackett
2ed05bec70 PEP8 cleanups. 2011-04-06 14:57:17 -07:00
Mike Dirolf
be157dd399 minor: another test fix 2010-06-16 15:05:58 -04:00
Mike Dirolf
64c0403d16 minor: fix test 2010-06-16 15:04:44 -04:00
Mike Dirolf
c2dc7856fa this test was buggy 2010-05-12 16:52:29 -04:00
Mike Dirolf
3d7240e57f It's 2010! 2010-01-30 10:48:26 -05:00
Mike Dirolf
826fb0d4db Simplification of connection pooling.
Makes driver ~2x faster for simple benchmarks.

DEPRECATED pool_size, auto_start_request and timeout parameters to Connection
DEPRECATED Connection.start_request

Each thread now gets it's own socket reserved on it's first operation. Those
sockets are held until Connection.end_request is called by that thread, or
Connection.disconnect is called by any thread, or the thread dies.

Calling Connection.end_request allows the socket to be returned to the pool,
and to be used by other threads instead of creating a new socket. Judicious use
of this method is important for applications with many threads or with long
running threads that make few calls to PyMongo operations.
2010-01-08 15:13:50 -05:00
Mike Dirolf
2a1c6968bc minor: oops forgot to update both places 2009-11-23 16:52:27 -05:00
Mike Dirolf
1adcc8ec25 minor: only retry 10 times so we don't run out of sockets on win32 2009-11-23 16:20:18 -05:00
Mike Dirolf
856926dbab minor: don't try to connect indefinitely 2009-11-23 15:04:30 -05:00
Mike Dirolf
62fab40b44 close a single socket instead of doing a full reset - fixes some race conditions we were running into 2009-11-23 14:43:27 -05:00
Mike Dirolf
9b7db6504f minor: update tests to work with changes to / on indexed fields 2009-10-21 14:53:32 -04:00
Mike Dirolf
9b3e1ce9ac minor: use no timeout for thread tests - get around some failures due to (i think) slowness in 2.4 2009-10-21 13:59:30 -04:00
Mike Dirolf
74b5e284d5 failing test case for safe mode with threading 2009-10-19 14:15:24 -04:00
Alexander Artemenko
6849fc7fa1 Added call to 'join' in threads test, to remove such ugly errors:
Exception in thread Thread-58 (most likely raised during interpreter shutdown): Exception in thread Thread-62 (most likely raised during interpreter shutdown):
    Traceback (most recent call last):
      File "/usr/lib/python2.5/threading.py", line 486, in __bootstrap_inner
      File "/home/art/git/mongo-python-driver/test/test_threads.py", line 31, in run
      File "/home/art/git/mongo-python-driver/pymongo/cursor.py", line 411, in next
    <type 'exceptions.TypeError'>: 'NoneType' object is not callable

Signed-off-by: Mike Dirolf <mike@dirolf.com>
2009-08-31 21:46:38 +08:00
Mike Dirolf
90beef7b20 minor: more PEP 8 2009-06-05 16:54:02 -04:00
Mike Dirolf
114f2f2e7c use database pymongo_test instead of test for testing 2009-01-29 14:14:54 -05:00
Mike Dirolf
b660722110 space 2009-01-23 16:34:48 -05:00
Mike Dirolf
e61baa8399 be threadsafe + test 2009-01-22 17:23:12 -05:00