chia-blockchain/tests/util
Kyle Altendorf 8ff73e961a
add LimitedSemaphore (#13642)
* treat Semaphore._waiters as length zero when it is None

We access the `._waiters` private attribute of the Python asyncio
`Semaphore` class.  This was changed in Python 3.10.8 (and other versions)
to be initialized to `None` instead of an empty deque.  Our existing
unconditional length checks failed on the new `None` default.  This seems
to block syncing.

https://github.com/python/cpython/pull/97020

https://github.com/python/cpython/compare/v3.10.7..v3.10.8#diff-0fee1befb15023abc0dad2623effa93a304946796929f6cb445d11a57821e737

Reported traceback:
```python-traceback
2022-10-12T20:03:59.367 full_node full_node_server : INFO Connected with full_node {'host': '65.34.144.6', 'port': 8444}
2022-10-12T20:03:59.370 full_node full_node_server : ERROR Exception: object of type 'NoneType' has no len(), {'host': '65.34.144.6', 'port': 8444}. Traceback (most recent call last):
File "/home/summa/chia-blockchain/chia/server/server.py", line 598, in wrapped_coroutine
result = await coroutine
File "/home/summa/chia-blockchain/chia/full_node/full_node_api.py", line 114, in new_peak
waiter_count = len(self.full_node.new_peak_sem._waiters)
TypeError: object of type 'NoneType' has no len()

2022-10-12T20:03:59.371 full_node full_node_server : ERROR Exception: object of type 'NoneType' has no len() <class 'TypeError'>, closing connection {'host': '65.34.144.6', 'port': 8444}. Traceback (most recent call last):
File "/home/summa/chia-blockchain/chia/server/server.py", line 608, in api_call
response: Optional[Message] = await asyncio.wait_for(wrapped_coroutine(), timeout=timeout)
File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
return await fut
File "/home/summa/chia-blockchain/chia/server/server.py", line 605, in wrapped_coroutine
raise e
File "/home/summa/chia-blockchain/chia/server/server.py", line 598, in wrapped_coroutine
result = await coroutine
File "/home/summa/chia-blockchain/chia/full_node/full_node_api.py", line 114, in new_peak
waiter_count = len(self.full_node.new_peak_sem._waiters)
TypeError: object of type 'NoneType' has no len()

2022-10-12T20:03:59.487 full_node full_node_server : INFO Connection closed: 65.34.144.6, node id: 506fe4c05ce6b72bb707471842e552307c7a547aa9ba981175db5c08fa3e47e6
```

* add LimitedSemaphore
2022-11-06 11:38:25 -06:00
..
__init__.py Added tests, improved serialization 2019-08-05 14:38:16 +09:00
alert_server.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
benchmark_cost.py Move simulator test requirements over to new module (#12521) 2022-07-25 14:07:38 -05:00
bip39_test_vectors.json util: Drop partially implemented BIP39 passphrase support (#12748) 2022-08-06 09:50:33 -05:00
blockchain.py make DBWrapper2 handle more connection setup (#13510) 2022-09-26 11:17:20 -05:00
build_network_protocol_files.py Request header blocks, and new rate limits (#11636) 2022-06-11 01:35:41 -05:00
config.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
db_connection.py convert datalayer to DBWrapper2 (#13582) 2022-10-03 17:50:12 -05:00
gen_ssl_certs.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
generator_tools_testing.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
key_tool.py Move simulator test requirements over to new module (#12521) 2022-07-25 14:07:38 -05:00
keyring.py util: Free all non-class related functions in FileKeyring (#12655) 2022-07-29 11:35:08 -05:00
misc.py test service shutdown response to signals (#13576) 2022-10-20 16:08:49 -04:00
network_protocol_data.py Request header blocks, and new rate limits (#11636) 2022-06-11 01:35:41 -05:00
protocol_messages_bytes-v1.0 Request header blocks, and new rate limits (#11636) 2022-06-11 01:35:41 -05:00
protocol_messages_json.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
rpc.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
temp_file.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
test_chunks.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
test_full_block_utils.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
test_limited_semaphore.py add LimitedSemaphore (#13642) 2022-11-06 11:38:25 -06:00
test_lock_queue.py remove some event_loop() fixtures (#10420) 2022-03-14 06:08:35 -07:00
test_misc.py embrace click 8 (#13559) 2022-09-29 11:24:36 -05:00
test_network_protocol_files.py Ms.mypy enable (#13320) 2022-09-08 12:57:15 -05:00
test_network_protocol_json.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
test_network_protocol_test.py Fee estimation. (#13645) 2022-10-18 09:12:22 -05:00
test_network.py Add Windows CI (#10681) 2022-05-31 14:04:45 -05:00
test_paginator.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00
test_struct_stream.py Catchup/long lived atari from release 1.4.0 46ebed37d8 (#11648) 2022-05-26 18:11:21 -07:00
wallet_is_synced.py configure isort to add the future annotations import (#13327) 2022-09-30 03:40:22 -05:00