Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(145)

Delta Between Two Patch Sets: Lib/test/test_selectors.py

Issue 22043: Use a monotonic clock to compute timeouts
Left Patch Set: Created 3 years, 2 months ago
Right Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/telnetlib.py ('k') | Lib/threading.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 import errno 1 import errno
2 import os 2 import os
3 import random 3 import random
4 import selectors 4 import selectors
5 import signal 5 import signal
6 import socket 6 import socket
7 from test import support 7 from test import support
8 from time import sleep 8 from time import sleep
9 import unittest 9 import unittest
10 import unittest.mock 10 import unittest.mock
11 from time import monotonic as time 11 from time import monotonic as time
12 try: 12 try:
13 import resource 13 import resource
14 except ImportError: 14 except ImportError:
15 resource = None 15 resource = None
16 16
17 17
18 if hasattr(socket, 'socketpair'): 18 if hasattr(socket, 'socketpair'):
19 socketpair = socket.socketpair 19 socketpair = socket.socketpair
20 else: 20 else:
21 def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0): 21 def socketpair(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0):
22 with socket.socket(family, type, proto) as l: 22 with socket.socket(family, type, proto) as l:
23 l.bind((support.HOST, 0)) 23 l.bind((support.HOST, 0))
24 l.listen(3) 24 l.listen()
25 c = socket.socket(family, type, proto) 25 c = socket.socket(family, type, proto)
26 try: 26 try:
27 c.connect(l.getsockname()) 27 c.connect(l.getsockname())
28 caddr = c.getsockname() 28 caddr = c.getsockname()
29 while True: 29 while True:
30 a, addr = l.accept() 30 a, addr = l.accept()
31 # check that we've got the correct client 31 # check that we've got the correct client
32 if addr == caddr: 32 if addr == caddr:
33 return c, a 33 return c, a
34 a.close() 34 a.close()
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 def test_main(): 449 def test_main():
450 tests = [DefaultSelectorTestCase, SelectSelectorTestCase, 450 tests = [DefaultSelectorTestCase, SelectSelectorTestCase,
451 PollSelectorTestCase, EpollSelectorTestCase, 451 PollSelectorTestCase, EpollSelectorTestCase,
452 KqueueSelectorTestCase, DevpollSelectorTestCase] 452 KqueueSelectorTestCase, DevpollSelectorTestCase]
453 support.run_unittest(*tests) 453 support.run_unittest(*tests)
454 support.reap_children() 454 support.reap_children()
455 455
456 456
457 if __name__ == "__main__": 457 if __name__ == "__main__":
458 test_main() 458 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7