diff --git a/.efrocachemap b/.efrocachemap index 5c31f527..cd556947 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -420,7 +420,7 @@ "assets/build/ba_data/audio/zoeOw.ogg": "https://files.ballistica.net/cache/ba1/51/eb/0a567253cc08c94c5d315a64d9af", "assets/build/ba_data/audio/zoePickup01.ogg": "https://files.ballistica.net/cache/ba1/bc/8f/a9c51a09c418136e386b7fdf21c7", "assets/build/ba_data/audio/zoeScream01.ogg": "https://files.ballistica.net/cache/ba1/02/e5/84916e123f47ccf11ddda380d699", - "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/2a/49/fd32ca142f5a6a48df4a2616bb91", + "assets/build/ba_data/data/langdata.json": "https://files.ballistica.net/cache/ba1/f9/ed/20354b5a613c3e168d9a3b92ed05", "assets/build/ba_data/data/languages/arabic.json": "https://files.ballistica.net/cache/ba1/ca/75/3de74bd6e498113b99bbf9eda645", "assets/build/ba_data/data/languages/belarussian.json": "https://files.ballistica.net/cache/ba1/55/8c/8d0a0585e434b94865ae4befc090", "assets/build/ba_data/data/languages/chinese.json": "https://files.ballistica.net/cache/ba1/f6/21/951b7ff02b0ad14b1f0ac55763c4", @@ -435,7 +435,7 @@ "assets/build/ba_data/data/languages/french.json": "https://files.ballistica.net/cache/ba1/b6/e0/37dd30b686f475733ccc4b3cab49", "assets/build/ba_data/data/languages/german.json": "https://files.ballistica.net/cache/ba1/20/3f/198dcc5cfed5789042e1595bd048", "assets/build/ba_data/data/languages/gibberish.json": "https://files.ballistica.net/cache/ba1/03/6a/4db89c5bf1ced8eb5a5615a4ae64", - "assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/8c/8e/67de1d9997a66299c8881d44ab22", + "assets/build/ba_data/data/languages/greek.json": "https://files.ballistica.net/cache/ba1/82/eb/37ff44af76812097f9c98f05c730", "assets/build/ba_data/data/languages/hindi.json": "https://files.ballistica.net/cache/ba1/08/3b/68cea4d16f7020d932829af85323", "assets/build/ba_data/data/languages/hungarian.json": "https://files.ballistica.net/cache/ba1/2d/e5/3737c6c3979cf381321c5472bea5", "assets/build/ba_data/data/languages/indonesian.json": "https://files.ballistica.net/cache/ba1/75/70/e33e6ee95830052e8f36cd2135f7", @@ -3971,50 +3971,50 @@ "assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e", "assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34", "ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a", - "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0e/f4/14cd29df816ea160f38ec07f5be0", - "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/0d/20/deaf28c929ac5e949abf69c7fc01", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a4/ec/7a760352cba96a04daa07b8a3b2e", - "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/fe/7b/84075f59a7289942ec3f0ed1f2a1", - "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ce/2d/6783aeab59b729bb1fab72fbf257", - "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/41/6b/3cd3898ca28daad4370e05134120", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e2/0f/f7e3ce700af958929381407d1f23", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/24/25/aeb8f95972783d6449cb232b684d", - "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/cd/a3/d8736610dad499baba5021e0792d", - "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/3e/67/bf7aeb91374f0d70db02625afefe", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9d/fc/399c9c1eeed22e8a206d3d814032", - "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f7/fb/44744a11dff5ba4799fa496ee153", - "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/74/88/46c54775da894079d2e0f789d531", - "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/34/02/a95cb17dc427427d5066f8562819", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/f4/0f/7eef9b4a5572fdaa152b37fd4aec", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ab/b7/9f5fd8ecb70ec2f6cc345275b772", - "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/24/81/ab9edbb2956644407dec33e774cc", - "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/e9/2b/157541c1c5eaa9ea0022345d9e14", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/c0/13/f738bed6f7d18958f0ae8add008f", - "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/8d/11/b025e130df9e0f02fdd36a389198", - "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/89/e7/bddebae8f1238053c424601c2e1b", - "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8f/e9/0dbdd88e200fad78ce9ca8af72e0", - "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8a/41/0aa39ae1cf0f1939b3a6f25f61a1", - "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/18/c7/1f9f11e753dbfd3ce17b1a355b7d", - "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e5/35/4b65f05089a8dc7552e1d6efeb7e", - "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5c/3b/8bf5b65f7ba311116ea71c0f157a", - "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/07/6d/3441c6c39ec55e532ad0e2295e54", - "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/21/b0/fe3a4950958bcef9b4e7c09ca1d6", - "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ad/db/5ca0536cef4adad5c20ef8a21c15", - "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/55/d3/511833367da7546a2fe143e94c48", - "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5b/64/4536316032cca40227c045c99b8a", - "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6d/da/bf1b3d173484c6a46022ade973bf", - "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/11/b3/aa5493d4e7c19daedd17474d89e6", - "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6e/df/ce8a87922ff11b26579c7fb0021a", - "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7c/b1/2f659ec3185311272e7f1e395255", - "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/97/82/4dd06b79621e5574a257b0882648", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/6a/a9/55cebf162399d05e0bf21c99824e", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/e9/79/64eb631a83b3eccfa3e4a96d8e68", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/c2/2f/5798ecdc59137d0dc22876414266", - "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/75/91/f1164a24dfceb696203dbf6234e7", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/d5/fc/dd2eeee001240769b1519479ed96", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/ec/68/7dccf018cbc1b22d1bca4fda8661", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/6c/36/95abf8c01f69623b46bdf5b6c89b", - "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/5d/86/8544d30ca45db41c3e79c32e4cd5", + "build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/fd/f8/10dab633b840e11d48028ece0e94", + "build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/95/5c/25082f7cccc42c15e5b83c75c475", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5e/97/9e0e1c1dc834ad181859b0ee0b78", + "build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/89/b2/1c0acb568e9c59ac9fd5874cae5f", + "build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/0b/18/2bc39720f1316779415cc94cb113", + "build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/ac/a7/6a840428e14ef51bcd0df363a434", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c2/41/0c32e18e1e70a972a1115e92e186", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/47/64/7ccc6f00b6956c1a7432432549bd", + "build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c9/4f/5440667c1b6fea19ae0de266bfd8", + "build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/32/f0/239dbf6e7dd3cd3db7486fde7407", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/98/72/6c901ee766aebf76fb80eae90589", + "build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/db/1e/6774a41b43542afc038908d8e89b", + "build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/df/d2/1fd51009e9fb22045c2a583cd64a", + "build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/fd/81/3fc11ac92e6ebcec071c7f93ffe7", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/33/7b/20b1def5897ee9f60817b75cb51f", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/51/13/b66b6692b578e3c1b7a253ac764e", + "build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/06/e4/45df563117d8cc07f606d3df504f", + "build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/cf/d4/885ba111bb2b13084cf31f64cede", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/20/2d/3c0bc587aea1bd0e04702bfe2291", + "build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/19/25/9ae33702dec28a19114b023f9dd5", + "build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c2/86/37c7b19623c5f72eb4223f1fa6a2", + "build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f2/ee/e42d3fe7a0d2ad6a4395c6b5fd1f", + "build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/27/4a/439e5c93cf7fdf31893dcc1cfaa3", + "build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cf/4e/a1085b9060bb4c7ee260bcd3291c", + "build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/84/42/59f61b5645662d30c1ad2c6410b9", + "build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/3d/f8/9298792aa9378a520596bba6a388", + "build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/27/bb/cae4aa7229c869262db19e9dcdd8", + "build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5a/de/1e35235ed2b1279fd95b845ed04d", + "build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/05/e570e9edd509552a3d2028ab099d", + "build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/20/e9/9a956250851d65a3602c20ae990a", + "build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/09/1c/d3536f33192842c6b30b06771611", + "build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0c/4a/77171c3984442e73727bbf47ddec", + "build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a1/a7/25adabdaa21491cd25ef28a4f846", + "build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/ba/0f/eaee0823fe7a1f299e3a19578451", + "build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/66/fe/17320024436fd49b4d8886075fc9", + "build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c4/77/17075093fd218bd46e6dad294f3f", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/f3/f3/a31d843c10f30086f84368376b35", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/c9/e9/221a9f0d18117353851624446b32", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/c3/54/0de51809c3a7edf28c38dd144a10", + "build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/03/4d/76acfd2bcd4c0c94a85e450bc3d3", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/a4/94/76a46fa659db22ca2155e1b423a9", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/60/a3/5e7fe045108577d6c17076838c99", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/9d/5d/7d24ce4b8cccfca69c593ff59bfe", + "build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/c9/4c/751c6d0ea202603d20385aaa1d94", "src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/b3/15/7c6d580b3482870b5b058858624c", "src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/d3/db/e73d4dcf1280d5f677c3cf8b47c3" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 167c477c..05929c7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.6.12 (20554, 2022-04-15) +### 1.6.12 (20556, 2022-04-19) - More internal work on V2 master-server communication ### 1.6.11 (20539, 2022-03-23) diff --git a/src/ballistica/ballistica.cc b/src/ballistica/ballistica.cc index 2c135372..1862cc92 100644 --- a/src/ballistica/ballistica.cc +++ b/src/ballistica/ballistica.cc @@ -21,7 +21,7 @@ namespace ballistica { // These are set automatically via script; don't modify them here. -const int kAppBuildNumber = 20554; +const int kAppBuildNumber = 20556; const char* kAppVersion = "1.6.12"; // Our standalone globals. diff --git a/tools/efro/rpc.py b/tools/efro/rpc.py index ae70399c..9ff1d3a3 100644 --- a/tools/efro/rpc.py +++ b/tools/efro/rpc.py @@ -104,14 +104,20 @@ class RPCEndpoint: handle_raw_message_call: Callable[[bytes], Awaitable[bytes]], reader: asyncio.StreamReader, writer: asyncio.StreamWriter, - debug_print: bool, label: str, + debug_print: bool = False, + debug_print_io: bool = False, + debug_print_call: Callable[[str], None] = None, keepalive_interval: float = DEFAULT_KEEPALIVE_INTERVAL, keepalive_timeout: float = DEFAULT_KEEPALIVE_TIMEOUT) -> None: self._handle_raw_message_call = handle_raw_message_call self._reader = reader self._writer = writer self._debug_print = debug_print + self._debug_print_io = debug_print_io + if debug_print_call is None: + debug_print_call = print + self._debug_print_call: Callable[[str], None] = debug_print_call self._label = label self._thread = current_thread() self._closing = False @@ -138,7 +144,8 @@ class RPCEndpoint: if self._debug_print: peername = self._writer.get_extra_info('peername') - print(f'{self._label}: connected to {peername} at {self._tm()}.') + self._debug_print_call( + f'{self._label}: connected to {peername} at {self._tm()}.') async def run(self) -> None: """Run the endpoint until the connection is lost or closed. @@ -182,7 +189,7 @@ class RPCEndpoint: logging.exception('Error closing %s.', self._label) if self._debug_print: - print(f'{self._label}: finished.') + self._debug_print_call(f'{self._label}: finished.') async def send_message(self, message: bytes, @@ -229,11 +236,13 @@ class RPCEndpoint: return await asyncio.wait_for(msgobj.wait_task, timeout=timeout) except asyncio.CancelledError as exc: if self._debug_print: - print(f'{self._label}: message {message_id} was cancelled.') + self._debug_print_call( + f'{self._label}: message {message_id} was cancelled.') raise CommunicationError() from exc except asyncio.TimeoutError as exc: if self._debug_print: - print(f'{self._label}: message {message_id} timed out.') + self._debug_print_call( + f'{self._label}: message {message_id} timed out.') # Stop waiting on the response. msgobj.wait_task.cancel() @@ -252,18 +261,18 @@ class RPCEndpoint: return if self._debug_print: - print(f'{self._label}: closing...') + self._debug_print_call(f'{self._label}: closing...') self._closing = True # Kill all of our in-flight tasks. if self._debug_print: - print(f'{self._label}: cancelling tasks...') + self._debug_print_call(f'{self._label}: cancelling tasks...') for task in self._get_live_tasks(): task.cancel() if self._debug_print: - print(f'{self._label}: closing writer...') + self._debug_print_call(f'{self._label}: closing writer...') self._writer.close() # We don't need this anymore and it is likely to be creating a @@ -286,12 +295,14 @@ class RPCEndpoint: if not self._closing: raise RuntimeError('Must be called after close()') + live_tasks = self._get_live_tasks() if self._debug_print: - print(f'{self._label}: waiting for close to complete...') + self._debug_print_call( + f'{self._label}: waiting for tasks to finish: ' + f' ({live_tasks=})...') # Wait for all of our in-flight tasks to wrap up. - results = await asyncio.gather(*self._get_live_tasks(), - return_exceptions=True) + results = await asyncio.gather(*live_tasks, return_exceptions=True) for result in results: # We want to know if any errors happened aside from CancelledError # (which are BaseExceptions, not Exception). @@ -301,6 +312,10 @@ class RPCEndpoint: 'Got unexpected error cleaning up %s task: %s', self._label, result) + if self._debug_print: + self._debug_print_call( + f'{self._label}: tasks finished; waiting for writer close...') + # At this point we shouldn't touch our tasks anymore. # Clearing them out allows us to go down # del self._tasks @@ -319,8 +334,9 @@ class RPCEndpoint: logging.exception('Error closing _writer for %s.', self._label) else: if self._debug_print: - print(f'{self._label}: silently ignoring error in' - f' _writer.wait_closed(): {exc}.') + self._debug_print_call( + f'{self._label}: silently ignoring error in' + f' _writer.wait_closed(): {exc}.') def _tm(self) -> str: """Simple readable time value for debugging.""" @@ -339,7 +355,8 @@ class RPCEndpoint: self._peer_info = dataclass_from_json(_PeerInfo, message.decode()) self._last_keepalive_receive_time = time.monotonic() if self._debug_print: - print(f'{self._label}: received handshake at {self._tm()}.') + self._debug_print_call( + f'{self._label}: received handshake at {self._tm()}.') # Now just sit and handle stuff as it comes in. while True: @@ -351,9 +368,9 @@ class RPCEndpoint: raise RuntimeError('Got multiple handshakes') if mtype is _PacketType.KEEPALIVE: - if self._debug_print: - print(f'{self._label}: received keepalive' - f' at {self._tm()}.') + if self._debug_print_io: + self._debug_print_call(f'{self._label}: received keepalive' + f' at {self._tm()}.') self._last_keepalive_receive_time = time.monotonic() elif mtype is _PacketType.MESSAGE: @@ -369,9 +386,9 @@ class RPCEndpoint: msgid = await self._read_int_16() msglen = await self._read_int_16() msg = await self._reader.readexactly(msglen) - if self._debug_print: - print(f'{self._label}: received message {msgid}' - f' of size {msglen} at {self._tm()}.') + if self._debug_print_io: + self._debug_print_call(f'{self._label}: received message {msgid}' + f' of size {msglen} at {self._tm()}.') # Create a message-task to handle this message and return # a response (we don't want to block while that happens). @@ -381,14 +398,15 @@ class RPCEndpoint: weakref.ref( asyncio.create_task( self._handle_raw_message(message_id=msgid, message=msg)))) - print(f'{self._label}: done handling message at {self._tm()}.') + self._debug_print_call( + f'{self._label}: done handling message at {self._tm()}.') async def _handle_response_packet(self) -> None: msgid = await self._read_int_16() rsplen = await self._read_int_16() - if self._debug_print: - print(f'{self._label}: received response {msgid}' - f' of size {rsplen} at {self._tm()}.') + if self._debug_print_io: + self._debug_print_call(f'{self._label}: received response {msgid}' + f' of size {rsplen} at {self._tm()}.') rsp = await self._reader.readexactly(rsplen) msgobj = self._in_flight_messages.get(msgid) if msgobj is None: @@ -396,8 +414,9 @@ class RPCEndpoint: # that has timed out. In this case we will have no local # record of it. if self._debug_print: - print(f'{self._label}: got response for nonexistent' - f' message id {msgid}; perhaps it timed out?') + self._debug_print_call( + f'{self._label}: got response for nonexistent' + f' message id {msgid}; perhaps it timed out?') else: msgobj.set_response(rsp) @@ -456,8 +475,9 @@ class RPCEndpoint: self._keepalive_timeout): if self._debug_print: since = now - self._last_keepalive_receive_time - print(f'{self._label}: reached keepalive time-out' - f' ({since:.1f}s).') + self._debug_print_call( + f'{self._label}: reached keepalive time-out' + f' ({since:.1f}s).') raise _KeepaliveTimeoutError() async def _run_core_task(self, tasklabel: str, call: Awaitable) -> None: @@ -471,12 +491,14 @@ class RPCEndpoint: self._label, tasklabel) else: if self._debug_print: - print(f'{self._label}: {tasklabel} task will exit cleanly' - f' due to {exc!r}.') + self._debug_print_call( + f'{self._label}: {tasklabel} task will exit cleanly' + f' due to {exc!r}.') finally: # Any core task exiting triggers shutdown. if self._debug_print: - print(f'{self._label}: {tasklabel} task exiting...') + self._debug_print_call( + f'{self._label}: {tasklabel} task exiting...') self.close() async def _handle_raw_message(self, message_id: int, @@ -531,10 +553,9 @@ class RPCEndpoint: """Enqueue a raw packet to be sent. Must be called from our loop.""" self._check_env() - if bool(True): - if self._debug_print: - print(f'{self._label}: enqueueing outgoing packet' - f' {data[:50]!r} at {self._tm()}.') + if self._debug_print_io: + self._debug_print_call(f'{self._label}: enqueueing outgoing packet' + f' {data[:50]!r} at {self._tm()}.') # Add the data and let our write task know about it. self._out_packets.append(data)