[Freeswitch-users] OSError when using Python ESL + socketserver

René Weiss rw at panorgan.ch
Fri Jun 26 12:21:55 UTC 2020


Hi,

When I'm using the ESL library (python-ESL==1.4.18) for Python (3.7.7)
together with socketserver I always get an OSError when the connection
is closing.

Here some sample code (mostly the example from the wiki ported to Python 3):

-----------
import socketserver
import ESL

class ESLReqHandler(socketserver.BaseRequestHandler):
     def setup(self):
         print(self.client_address, 'connected!')

         fd = self.request.fileno()
         print(fd)

         con = ESL.ESLconnection(fd)
         print('Connected: ', con.connected())

         if con.connected():

             info = con.getInfo()

             uuid = info.getHeader("unique-id")
             print(uuid)
             con.execute("answer", "", uuid)
             con.execute("sleep", "2000", uuid)


server = socketserver.ThreadingTCPServer(('', 8040), ESLReqHandler)
server.serve_forever()
-----------

And this is the error message I get:

-----------
Exception in thread Thread-1:
Traceback (most recent call last):
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
     self.run()
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
     self._target(*self._args, **self._kwargs)
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 654, in process_request_thread
     self.shutdown_request(request)
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 509, in shutdown_request
     self.close_request(request)
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 513, in close_request
     request.close()
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 420, in close
     self._real_close()
   File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 414, in _real_close
     _ss.close(self)
OSError: [Errno 9] Bad file descriptor
-----------

The problem starts to appear as soon as the command "ESL.ESLconnection(fd)"
is included in the setup function.

Any ideas?

Thanks
René Weiss



More information about the FreeSWITCH-users mailing list