Issue2192

classification
Title: Server requests hanging using jython, django and django-jython
Type: Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: smetz, zyasoft
Priority: high Keywords:

Created on 2014-08-14.23:59:14 by smetz, last changed 2014-10-05.16:36:48 by zyasoft.

Messages
msg8926 (view) Author: Sara (smetz) Date: 2014-08-14.23:59:14
We are currently using Django 1.7, Jython 2.7b3+ and django-jython 1.7.0b2 to run our server.
Commit https://github.com/jythontools/jython/commit/348b63a04e2b20ca8b91bd367b7f778d66379381
to solve issue http://bugs.jython.org/issue2094 is causing requests to hang indefinitely.

This change seems to be the root of the issue:

@@ -818,19 +881,21 @@ def connect_ex(self, addr):

     def listen(self, backlog):
         self.socket_type = SERVER_SOCKET
+        self.child_queue = ArrayBlockingQueue(backlog)
+        self.accepted_children = 1  # include the parent as well to simplify close logic

         b = ServerBootstrap()
-        self.group = NioEventLoopGroup(10, DaemonThreadFactory())
-        b.group(self.group)
+        self.parent_group = NioEventLoopGroup(2, DaemonThreadFactory("Jython-Netty-Parent-%s"))
+        self.child_group = NioEventLoopGroup(2, DaemonThreadFactory("Jython-Netty-Child-%s"))
+        b.group(self.parent_group, self.child_group)

Increasing the number of threads from 2 seemed to prevent the problem.
msg8927 (view) Author: Jim Baker (zyasoft) Date: 2014-08-15.02:05:43
Thanks. I had reduced thread pool size because we have been experiencing thread leaks in some tests due to the lack of __del__ support, but that's forthcoming. Restoring to a reasonable sizing like 10 seems to be the best action for now; we can make configurable or smarter in sizing later.
msg8950 (view) Author: Jim Baker (zyasoft) Date: 2014-09-05.16:22:23
Fixed as of http://hg.python.org/jython/rev/7a96264b09ab
msg8951 (view) Author: Jim Baker (zyasoft) Date: 2014-09-05.16:25:29
__del__ now works in general for Jython (see #1057), although we still have the first thread in each pool hanging, but not apparently sockets.

As a consequence, I've been able to increase the thread pool count to 10. We will work on getting the final thread cleanup as well, although it most likely only impacts test code.
msg9014 (view) Author: Jim Baker (zyasoft) Date: 2014-09-22.22:39:59
Also just fixed the related #2201, which was causing a separate issue in closing out thread pools
History
Date User Action Args
2014-10-05 16:36:48zyasoftsetstatus: pending -> closed
2014-09-22 22:40:00zyasoftsetmessages: + msg9014
2014-09-05 16:25:29zyasoftsetmessages: + msg8951
2014-09-05 16:22:23zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg8950
2014-08-15 02:06:00zyasoftsetpriority: high
assignee: zyasoft
resolution: accepted
2014-08-15 02:05:43zyasoftsetnosy: + zyasoft
messages: + msg8927
2014-08-14 23:59:14smetzcreate