Commit Graph

32 Commits

Author SHA1 Message Date
A. Jesse Jiryu Davis
4618998dd1 PYTHON-983 Idle monitor threads use excessive CPU. 2015-10-14 23:52:18 -04:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
A. Jesse Jiryu Davis
e7b0596442 PYTHON-785 Remove start_request().
Remove MongoClient's methods start_request(), in_request(), and end_request().
The purpose of requests was to provide read-your-writes consistency when using
w=0 write concern. Starting a request pins a socket to a thread so any
operations on that thread end up in the same queue on the server side.

Justification for removing: mongos 2.6+ doesn't support socket pinning by
default, and mongos 2.8+ doesn't support it at all (SERVER-12273), so whatever
weak consistency guarantees a request was supposed to provide are not provided
with sharding.

It's unnecessary with MongoDB 2.6+ since write commands always block and send a
response.

It's a confusing feature that should rarely be used, if ever, yet people
incorrectly use it all the time. It makes our connection pool unmaintainable to
any but the most expert developers.
2014-11-24 22:48:44 -05:00
A. Jesse Jiryu Davis
54a9769402 Use a monotonic clock if possible. 2014-11-21 21:09:07 -05:00
A. Jesse Jiryu Davis
f91c3d61cb Use with-statements to acquire locks.
We can use with-statements now that we've dropped support
for Python 2.4.
2014-10-02 10:07:43 -04:00
A. Jesse Jiryu Davis
98afef5871 Replace "Cluster" term with "Topology".
The Server Discovery And Monitoring Spec has replaced the term "cluster"
with "topology", since "cluster" in MongoDB terminology should be reserved
for sharded clusters. "Topology" describes a single server, replica set, or a
set of mongoses.

The previous commit replaced "cluster" with "topology" in file names. Here
I replace the term in class and variable names.
2014-09-17 22:32:43 -04:00
A. Jesse Jiryu Davis
2f9d24ade6 PYTHON-525 Reimplement MongoClient to use Cluster.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.

Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
2014-08-28 16:57:57 -04:00
A. Jesse Jiryu Davis
7c5c23bf60 PYTHON-525 Avoid lost notifications in Monitor.request_check().
If another thread called Monitor.request_check() while the Monitor was in run(),
right after _check_with_retry() and before it acquired the lock, the Monitor
would miss the notification and wait "heartbeat_frequency" before checking
again.

Doesn't matter in real life, since re-checking a server a millisecond after the
last check isn't useful, but important for tests that change state and immediately
call request_check().
2014-07-30 20:05:29 -04:00
A. Jesse Jiryu Davis
1bfac99f08 PYTHON-724 Remove Gevent-specific code.
PyMongo 2.x has Gevent-specific code to support Gevent with or without
patch_thread. However, patch_socket is always required with Gevent.

In PyMongo 3, we remove all Gevent-specific code and rely on Gevent's
patch_all.

Remove the "use_greenlets" option and attribute for MongoClient and
MongoReplicaSetClient.
2014-07-17 15:09:46 -04:00
A. Jesse Jiryu Davis
df711f6422 Prevent possible ref cycle in Python 3, PYTHON-646. 2014-03-09 23:43:14 -04:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
A. Jesse Jiryu Davis
8f6a34326e Improve multithreaded connection and reconnection in MongoClient, PYTHON-487. 2013-12-04 21:09:15 -05:00
A. Jesse Jiryu Davis
263ac8f8b7 Prevent concurrent calls to Thread.start() and refactor RS client, PYTHON-560. 2013-11-04 15:37:21 -05:00
A. Jesse Jiryu Davis
edc23501f4 GreenletIdent cleanup. 2013-08-16 16:18:50 -04:00
seewindcn
e1b792848f Update thread_util.py
Pool object call GreenletIdent.watch(on_thread_died) and not unlink. if the greenlet is resident, greenlet._links is growth
2013-08-16 16:18:50 -04:00
A. Jesse Jiryu Davis
5a88c6c2f4 Update docs for new pool options. PYTHON-436 2013-08-16 09:43:50 -04:00
A. Jesse Jiryu Davis
9a0a2c41a9 Avoid DeprecationWarning with Gevent 1.0rc2 and later. PYTHON-545 2013-08-06 15:04:47 -04:00
A. Jesse Jiryu Davis
7e5c3760a6 Pool style and cleanup, unused code and imports 2013-05-22 20:33:16 -04:00
A. Jesse Jiryu Davis
0339411b01 Ident refactoring 2013-05-22 20:33:15 -04:00
A. Jesse Jiryu Davis
78d33653d4 Ident.watch must always be passed the thread id
Prevent temptation to regress to PYTHON-353 by accessing a threadlocal in a threadlocal's weakref callback
2013-05-22 20:33:15 -04:00
A. Jesse Jiryu Davis
7074f2f419 Race condition in Counter
If a thread id or greenlet id is reused, it could get a previous thread's / greenlet's counter value
2013-05-22 20:33:15 -04:00
A. Jesse Jiryu Davis
7015eeb566 Move Pool's semaphore-creation logic into thread_util 2013-05-22 20:33:15 -04:00
A. Jesse Jiryu Davis
ca899c80ca thread_util.have_gevent is more accurate than has_greenlets now
Pool(use_greenlets=True) now requires Gevent, not just greenlet
2013-05-22 20:33:15 -04:00
Justin Patrin
8fe3154138 PYTHON-436 Change max_pool_size to limit the maximum concurrent connections rather than just the idle connections in the pool. Also add support for waitQueueTimeoutMS and waitQueueMultiple. 2013-05-22 20:33:14 -04:00
A. Jesse Jiryu Davis
3cd50cceed Ensure ThreadIdent's lock is always released; improve comment PYTHON-509 2013-04-24 22:09:06 -04:00
A. Jesse Jiryu Davis
a82d6bea2d PYTHON-509 we need to synchronize the threadlocal for Python <= 2.7.0, not 2.7.1 2013-04-24 22:09:06 -04:00
A. Jesse Jiryu Davis
9a2fe4981e Fix PYTHON-509, rare connection leaks in Python <= 2.7.0 2013-04-24 20:45:38 -04:00
A. Jesse Jiryu Davis
e31a07a84c Refactor thread-/greenlet-local stuff from pool.py into thread_util.py PYTHON-428
Preparation for PYTHON-428
2012-12-31 13:05:21 -05:00
Mike Dirolf
0fe4b29197 remove thread_util 2010-01-08 17:38:46 -05:00
Mike Dirolf
b8b4a04442 PEP 8 - no functional changes 2009-06-05 16:19:49 -04:00
Mike Dirolf
20fe9cc253 the PEP 8 compatible names only work in >= 2.6 2009-06-04 12:22:50 -04:00
Mike Dirolf
cf308e3b09 TimeoutableLock 2009-05-28 14:18:28 -04:00