mirror of
https://github.com/jtauber/applepy.git
synced 2025-02-16 17:30:27 +00:00
add fileno() method to ControlHandler for better compatiblity with select()
This commit is contained in:
parent
0b86a8693f
commit
0604bd1515
@ -389,6 +389,9 @@ class ControlHandler:
|
|||||||
self.cpu.running = True
|
self.cpu.running = True
|
||||||
self.sock.send("resetting\n")
|
self.sock.send("resetting\n")
|
||||||
|
|
||||||
|
def fileno(self):
|
||||||
|
return self.sock.fileno()
|
||||||
|
|
||||||
def handle_read(self):
|
def handle_read(self):
|
||||||
buf = self.sock.recv(1024)
|
buf = self.sock.recv(1024)
|
||||||
if not buf:
|
if not buf:
|
||||||
@ -610,15 +613,14 @@ class CPU:
|
|||||||
timeout = 0
|
timeout = 0
|
||||||
if not self.running:
|
if not self.running:
|
||||||
timeout = 1
|
timeout = 1
|
||||||
sockets = [self.control_listener] + [x.sock for x in self.control]
|
sockets = [self.control_listener] + self.control
|
||||||
rs, _, _ = select.select(sockets, [], [], timeout)
|
rs, _, _ = select.select(sockets, [], [], timeout)
|
||||||
for s in rs:
|
for s in rs:
|
||||||
if s is self.control_listener:
|
if s is self.control_listener:
|
||||||
cs, _ = self.control_listener.accept()
|
cs, _ = self.control_listener.accept()
|
||||||
self.control.append(ControlHandler(self, cs))
|
self.control.append(ControlHandler(self, cs))
|
||||||
else:
|
else:
|
||||||
c = [x for x in self.control if x.sock is s][0]
|
s.handle_read()
|
||||||
c.handle_read()
|
|
||||||
|
|
||||||
count = 1000
|
count = 1000
|
||||||
while count > 0 and self.running:
|
while count > 0 and self.running:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user