Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
couchdb-pyt...@googlecode.com  
View profile  
 More options Nov 18 2011, 11:49 am
From: couchdb-pyt...@googlecode.com
Date: Fri, 18 Nov 2011 16:49:34 +0000
Local: Fri, Nov 18 2011 11:49 am
Subject: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 205 by wickedg...@gmail.com: Having a well-defined way to reset  
the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

What steps will reproduce the problem?
1. connect to couchdb
2. fork() the python process
3. try to use the db in the child process

What is the expected output? What do you see instead?

The child gets exceptions like:

   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
1003, in rows
     self._fetch()
   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
990, in _fetch
     data = self.view._exec(self.options)
   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
880, in _exec
     _, _, data = self.resource.get_json(**self._encode_options(options))
   File "/usr/local/lib/python2.7/dist-packages/couchdb/http.py", line 394,  
in get_json
     if 'application/json' in headers.get('content-type'):
TypeError: argument of type 'NoneType' is not iterable

and

   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
1003, in rows
     self._fetch()
   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
990, in _fetch
     data = self.view._exec(self.options)
   File "/usr/local/lib/python2.7/dist-packages/couchdb/client.py", line  
878, in _exec
     **self._encode_options(options))
   File "/usr/local/lib/python2.7/dist-packages/couchdb/http.py", line 401,  
in post_json
     data = json.decode(data.read())
   File "/usr/local/lib/python2.7/dist-packages/couchdb/http.py", line 94,  
in read
     bytes = self.resp.read(size)
   File "/usr/lib/python2.7/httplib.py", line 541, in read
     return self._read_chunked(amt)
   File "/usr/lib/python2.7/httplib.py", line 586, in _read_chunked
     raise IncompleteRead(''.join(value))
httplib.IncompleteRead: IncompleteRead(1258 bytes read)

What version of the product are you using? On what operating system?

v0.8 on Ubuntu, python 2.7

Please provide any additional information below.

I'm able to work around the problem by including code like the following  
under 0.8:

with my_db.resource.session.lock:
     my_db.resource.session.conns = {}

Trunk has a connection pool object, so it looks like that would now be:

with my_db.resource.session.connection_pool.lock:
     my_db.resource.session.connection_pool.conns = {}

Having this encapsulated in a public API function would be useful for  
us.  :)

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Nov 18 2011, 1:27 pm
From: couchdb-pyt...@googlecode.com
Date: Fri, 18 Nov 2011 18:27:16 +0000
Local: Fri, Nov 18 2011 1:27 pm
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #1 on issue 205 by djc.ochtman: Having a well-defined way to reset  
the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

Could we make the connection pool thread-local, or something like that?  
I.e. something that does the right thing without needing the user's  
cooperation.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Nov 18 2011, 2:03 pm
From: couchdb-pyt...@googlecode.com
Date: Fri, 18 Nov 2011 19:03:32 +0000
Local: Fri, Nov 18 2011 2:03 pm
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #2 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

That would be great, if something like that would work.  Threading.local  
won't do the trick by itself, though:

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import threading
>>> import os
>>> def f():

...   l = threading.local()
...   l.foo = 'bar'
...   pid = os.fork()
...   if pid == 0:
...     print dir(l)
...

>>> f()
>>> ['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'foo']

Namespacing the connections by os.getpid() would probably work for the fork  
case, though.  Something along the lines of:

# Session
def __init__(self, ...):
     ...
     self._connectionPool_dict = {}
     ...

@property
def connection_pool(self):
     if os.getpid() not in self._connectionPool_dict:
         self._connectionPool_dict.clear()
         self._connectionPool_dict[os.getpid()] = ConnectionPool(...)
     return self._connectionPool_dict[os.getpid()]

Not sure what the intended behavior is WRT threading, but that could be  
added to the mix too if desired.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Nov 22 2011, 5:28 am
From: couchdb-pyt...@googlecode.com
Date: Tue, 22 Nov 2011 10:28:32 +0000
Local: Tues, Nov 22 2011 5:28 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #3 on issue 205 by matt.goo...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

I have no objection to extending the connection pool - that's actually one  
of the reasons I extracted the code to the ConnectionPool class. However,  
isn't this just the common problem of forking a process with open file  
handles? The solution is generally to fork first and open files later.

So, in this particular case I think it's best to fork the process and  
create a new couchdb.Server or couchdb.Database instance in the child  
process for it to use.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Nov 22 2011, 1:37 pm
From: couchdb-pyt...@googlecode.com
Date: Tue, 22 Nov 2011 18:37:56 +0000
Local: Tues, Nov 22 2011 1:37 pm
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #4 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

That approach presumes a lot about the application design.  For my case,  
the parts doing the forking and the parts talking to couchdb are pretty  
loosely coupled, and broadcasting "hey, we just forked; reset all of your  
connections please" wouldn't be very clean (as attested to by the hack that  
I put in place to work around this issue for the time being).  I can't not  
connect to couchdb in the parent, because the information about what/when  
to fork is contained there.

I was surprised by the current couchdb-python behavior because I don't  
typically lump open files and http requests into the same stateful bucket -  
keep-alives seem like an implementation detail, in this case.  Not having  
customers have to be aware of and account for that would be nice.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Sep 21 2012, 5:46 pm
From: couchdb-pyt...@googlecode.com
Date: Fri, 21 Sep 2012 21:46:09 +0000
Local: Fri, Sep 21 2012 5:46 pm
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful
Updates:
        Owner: wickedg...@gmail.com
        Labels: Milestone-0.9

Comment #5 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

(No comment was entered for this change.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Oct 22 2012, 7:26 am
From: couchdb-pyt...@googlecode.com
Date: Mon, 22 Oct 2012 11:26:37 +0000
Local: Mon, Oct 22 2012 7:26 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #6 on issue 205 by djc.ochtman: Having a well-defined way to reset  
the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

Any progress on this?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Oct 22 2012, 7:43 am
From: couchdb-pyt...@googlecode.com
Date: Mon, 22 Oct 2012 11:43:41 +0000
Local: Mon, Oct 22 2012 7:43 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #7 on issue 205 by kxepal: Having a well-defined way to reset the  
connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

It's easy to fix, but hard to test due to there is one big god method  
Session.request. Is it allowed to apply additional refactoring during fix?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Oct 22 2012, 7:51 am
From: couchdb-pyt...@googlecode.com
Date: Mon, 22 Oct 2012 11:51:12 +0000
Local: Mon, Oct 22 2012 7:51 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #8 on issue 205 by djc.ochtman: Having a well-defined way to reset  
the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

Please do the refactoring in a separate patch first, then the fix after  
that. :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Oct 22 2012, 7:54 am
From: couchdb-pyt...@googlecode.com
Date: Mon, 22 Oct 2012 11:54:22 +0000
Local: Mon, Oct 22 2012 7:54 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #9 on issue 205 by kxepal: Having a well-defined way to reset the  
connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

Got it, thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Oct 22 2012, 11:58 am
From: couchdb-pyt...@googlecode.com
Date: Mon, 22 Oct 2012 15:58:01 +0000
Local: Mon, Oct 22 2012 11:58 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #10 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

I've been trying to reproduce a minimal test case for my original problem  
(forking), but haven't had any success in doing so against trunk.  I need  
to spin up a virtual env and try against 0.8; it's possible that the  
changes between 0.8 and now have fixed the problem already.  That would be  
nice, but I suspect that I'm just doing a poor job of simulating the  
conditions of my original problem.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Mar 7, 11:57 am
From: couchdb-pyt...@googlecode.com
Date: Thu, 07 Mar 2013 16:57:03 +0000
Local: Thurs, Mar 7 2013 11:57 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #11 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

We've worked around this issue in our application code.  I would like to  
remove the Milestone-0.9 label; any objections?

--
You received this message because this project is configured to send all  
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Mar 7, 11:58 am
From: couchdb-pyt...@googlecode.com
Date: Thu, 07 Mar 2013 16:58:03 +0000
Local: Thurs, Mar 7 2013 11:58 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful

Comment #12 on issue 205 by wickedg...@gmail.com: Having a well-defined way  
to reset the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

We've worked around this issue in our application code.  I would like to  
remove the Milestone-0.9 label; any objections?

--
You received this message because this project is configured to send all  
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
couchdb-pyt...@googlecode.com  
View profile  
 More options Mar 8, 2:58 am
From: couchdb-pyt...@googlecode.com
Date: Fri, 08 Mar 2013 07:58:38 +0000
Local: Fri, Mar 8 2013 2:58 am
Subject: Re: Issue 205 in couchdb-python: Having a well-defined way to reset the connection pool would be useful
Updates:
        Labels: -Milestone-0.9

Comment #13 on issue 205 by djc.ochtman: Having a well-defined way to reset  
the connection pool would be useful
http://code.google.com/p/couchdb-python/issues/detail?id=205

Consider it done. ;)

--
You received this message because this project is configured to send all  
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »