Skip to content

Commit 71b3c32

Browse files
committed
Make the Windows select call even shorter
1 parent 96164f8 commit 71b3c32

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

example_code/item_37.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,12 @@ def run(self):
6666

6767

6868
# Example 6
69-
import select
70-
import socket
71-
72-
# This is for supporting Windows specifically. Windows can't do a
73-
# select call with an empty list. Don't connect the socket to anything.
74-
# Waiting for it will do nothing.
75-
_s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
69+
import select, socket
7670

71+
# Creating the socket is specifically to support Windows. Windows can't do
72+
# a select call with an empty list.
7773
def slow_systemcall():
78-
select.select([_s], [], [], 0.1)
74+
select.select([socket.socket()], [], [], 0.1)
7975

8076

8177
# Example 7

0 commit comments

Comments
 (0)