I am currently trying to transition from asyncore
to asyncio
since I am porting some old code from python 27 to python 35. But I am not very familiar yet with both.
Here is a condensed version of the problematic part:
import socket
import asyncore
mapDict = {}
fc = FeedbackController(port)
fc.start()
class FeedbackController(object):
def __init__(self, port=None):
self.ipcchannel = IPCConnectionHandler(self, theMap=mapDict)
self.udpconnectionhandler = UDPDispatcher(self, theMap=mapDict)
def start(self):
asyncore.loop(timeout=60.0,map=theMap)
…
class UDPDispatcher(asyncore.dispatcher):
def __init__(self, theMap):
asyncore.dispatcher.__init__(self, map=theMap)
self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)
self.bind((LOCALHOST, FC_PORT))
class IPCConnectionHandler(asyncore.dispatcher):
def __init__(self,theMap=None):
asyncore.dispatcher.__init__(self, map=theMap)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.bind((LOCALHOST, IPC_PORT))
self.listen(5)
At the moment, I am running on Macos Sierra and it crashes when the asyncore.loop
is called
Any help on how to transition would be great