Issue2864

classification
Title: Importing second instance of httplib causes an error
Type: Severity: normal
Components: Core Versions: Jython 2.7.2
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rses
Priority: Keywords:

Created on 2020-03-05.18:45:58 by rses, last changed 2020-03-05.18:45:58 by rses.

Messages
msg13006 (view) Author: (rses) Date: 2020-03-05.18:45:58
I seem to have a very odd issue. If I use two PythonInterpreters to make two calls into httplib, the second invocation causes an error:

The Java usage of PythonInterpreter is:

    public static void main(String[] args) {
        try {
            PythonInterpreter pythonInterpreter = new PythonInterpreter();
            pythonInterpreter.exec("import httplib");
            pythonInterpreter.exec("print 'first invocation'");
            pythonInterpreter.exec("con = httplib.HTTPSConnection('slack.com')");
            pythonInterpreter.exec("con.request('GET', '/intl/en-gb/?eu_nc=1')");
            pythonInterpreter.close();

            pythonInterpreter = new PythonInterpreter();
            pythonInterpreter.exec("import httplib");
            pythonInterpreter.exec("print 'second invocation'");
            pythonInterpreter.exec("con = httplib.HTTPSConnection('slack.com')");
            pythonInterpreter.exec("con.request('GET', '/intl/en-gb/?eu_nc=1')");
            pythonInterpreter.close();
        } catch (Exception e) {
            System.out.println("Failed:");
            e.printStackTrace();
        }
    }


Results in:

first invocation
second invocation
org.python.netty.channel.AbstractChannel WARNING Force-closing a channel whose registration task was not accepted by an event loop: [id: 0x584e978d]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 1042, in request
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 1082, in _send_request
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 1038, in endheaders
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 882, in _send_output
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 844, in send
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 1255, in connect
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/httplib$py.class", line 820, in connect
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/_socket$py.class", line 1581, in create_connection
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/_socket$py.class", line 1581, in create_connection
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/_socket$py.class", line 1457, in meth
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/_socket$py.class", line 951, in connect
  File "/home/rs/.m2/repository/org/python/jython-standalone/2.7.2rc1/jython-standalone-2.7.2rc1.jar/Lib/_socket$py.class", line 919, in _connect
	at org.python.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:926)
	at org.python.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:353)
	at org.python.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:346)
	at org.python.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:828)
	at org.python.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:818)
	at org.python.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:471)
	at org.python.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:87)
	at org.python.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:81)
	at org.python.netty.channel.MultithreadEventLoopGroup.register(MultithreadEventLoopGroup.java:86)
	at org.python.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:315)
	at org.python.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:264)
	at org.python.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:260)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
java.util.concurrent.RejectedExecutionException: java.util.concurrent.RejectedExecutionException: event executor terminated
Failed:

Essentially, the second call to 'con.request()' results in the exception: java.util.concurrent.RejectedExecutionException: java.util.concurrent.RejectedExecutionException: event executor terminated


Can someone help me please?
History
Date User Action Args
2020-03-05 18:45:58rsescreate