Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. osmo_trap2cgi.py: Don't recurse in ctrl_client() Use a loop instead. Without it the script will eventually crash with a RecursionError. File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client await ctrl_client(proxy, reader, writer) File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) [...] File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client [...] RecursionError: maximum recursion depth exceeded in comparison Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Related: SYS#4399 --- M scripts/osmo_trap2cgi.py 1 file changed, 18 insertions(+), 15 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/scripts/osmo_trap2cgi.py b/scripts/osmo_trap2cgi.py index ad66e7b..ca73fa8 100755 --- a/scripts/osmo_trap2cgi.py +++ b/scripts/osmo_trap2cgi.py @@ -22,7 +22,7 @@ */ """ -__version__ = "0.0.1" # bump this on every non-trivial change +__version__ = "0.0.2" # bump this on every non-trivial change from functools import partial import configparser, argparse, time, os, asyncio, aiohttp @@ -190,29 +190,32 @@ return await reader.readexactly(num_bytes) except asyncio.IncompleteReadError: proxy.log.info('Failed to read %d bytes reconnecting to %s:%d...', num_bytes, proxy.ctrl_addr, proxy.ctrl_port) -await conn_client(proxy) +raise async def ctrl_client(proxy, rd, wr): """ -Recursively read CTRL stream and handle selected messages. +Read CTRL stream and handle selected messages. """ -header = await recon_reader(proxy, rd, 4) -data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) -proxy.dispatch(wr, data) -await ctrl_client(proxy, rd, wr) +while True: +header = await recon_reader(proxy, rd, 4) +data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) +proxy.dispatch(wr, data) async def conn_client(proxy): """ (Re)establish connection with CTRL server and pass Reader/Writer to CTRL handler. """ -try: -reader, writer = await asyncio.open_connection(proxy.ctrl_addr, proxy.ctrl_port) -proxy.log.info('Connected to %s:%d', proxy.ctrl_addr, proxy.ctrl_port) -await ctrl_client(proxy, reader, writer) -except OSError as e: -proxy.log.info('%s: %d seconds delayed retrying...', e, proxy.timeout) -await asyncio.sleep(proxy.timeout) -await conn_client(proxy) +while True: +try: +reader, writer = await asyncio.open_connection(proxy.ctrl_addr, proxy.ctrl_port) +proxy.log.info('Connected to %s:%d', proxy.ctrl_addr, proxy.ctrl_port) +await ctrl_client(proxy, reader, writer) +except OSError as e: +proxy.log.info('%s: %d seconds delayed retrying...', e, proxy.timeout) +await asyncio.sleep(proxy.timeout) +except asyncio.IncompleteReadError: +pass +proxy.log.info('Reconnecting...') if __name__ == '__main__': -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 3 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-MessageType: merged
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 3: Code-Review+2 Adding +2 based on previous comments from Max and my own review. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 3 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 26 Jun 2019 12:50:08 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 3: (3 comments) https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@193 PS1, Line 193: await conn_client(proxy) > We need to break this recursion as well. Done https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@211 PS1, Line 211: await ctrl_client(proxy, reader, writer) > We're more or less in the same boat then. :-) […] Done https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@215 PS1, Line 215: await conn_client(proxy) > Nothing special, the recursion variant seems easier to review/understand. Ok, thanks for the clarification. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 3 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 26 Jun 2019 12:49:13 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: msuraev Comment-In-Reply-To: pespin Comment-In-Reply-To: daniel Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
Hello msuraev, pespin, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 to look at the new patch set (#3). Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. osmo_trap2cgi.py: Don't recurse in ctrl_client() Use a loop instead. Without it the script will eventually crash with a RecursionError. File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client await ctrl_client(proxy, reader, writer) File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) [...] File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client [...] RecursionError: maximum recursion depth exceeded in comparison Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Related: SYS#4399 --- M scripts/osmo_trap2cgi.py 1 file changed, 18 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/45/14545/3 -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 3 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-MessageType: newpatchset
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 3: Ok, bumped the version of the script -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 3 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 26 Jun 2019 12:48:08 + Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 2: Agree with Max, let's increase the version. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 2 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-Comment-Date: Tue, 25 Jun 2019 09:19:58 + Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
msuraev has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 2: (1 comment) Looks good overall but I can't test it of course. The only thing I'd recommend is to bump the version so it'd be obvious whether you're using recursion or loop code. https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@215 PS1, Line 215: await conn_client(proxy) > Yes, see also my generic comment. So I'll try to get the recursion out of > this script. […] Nothing special, the recursion variant seems easier to review/understand. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 2 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: msuraev Gerrit-Reviewer: pespin Gerrit-Comment-Date: Mon, 24 Jun 2019 16:10:13 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Comment-In-Reply-To: daniel Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 2: I ran this script with timeout 0 against a closed port and before this patch the script would crash with a recursion error. With this it ran for a long time trying to reconnect. It also reconnected normally after closing an open connection. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 2 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-Comment-Date: Mon, 24 Jun 2019 15:47:06 + Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
Hello Max, pespin, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 to look at the new patch set (#2). Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. osmo_trap2cgi.py: Don't recurse in ctrl_client() Use a loop instead. Without it the script will eventually crash with a RecursionError. File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client await ctrl_client(proxy, reader, writer) File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) [...] File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client [...] RecursionError: maximum recursion depth exceeded in comparison Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Related: SYS#4399 --- M scripts/osmo_trap2cgi.py 1 file changed, 17 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/45/14545/2 -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 2 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-MessageType: newpatchset
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 1: (2 comments) https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@193 PS1, Line 193: await conn_client(proxy) We need to break this recursion as well. https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@215 PS1, Line 215: await conn_client(proxy) > Then we should turn this recursion into a while True. Yes, see also my generic comment. So I'll try to get the recursion out of this script. Maybe Max can share his ideas why he used it in the first place. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Max Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 19 Jun 2019 16:07:35 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 1: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@215 PS1, Line 215: await conn_client(proxy) Then we should turn this recursion into a while True. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 19 Jun 2019 15:58:10 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@211 PS1, Line 211: await ctrl_client(proxy, reader, writer) > I don't know how this framework works, but are you sure keeping ctrl_client > in a while True loop is […] We're more or less in the same boat then. :-) As far as I can tell conn_client (re-)connects - see also line 215 - to the ctrl port and ctrl_client reads the traps in an infinite loop (or before in an infinite tail-recursion). If anything goes wrong in the exception handlers conn_client is called again, which re-establishes the connection. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 19 Jun 2019 15:49:20 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 1: It seems to me that tail-recursion should be possible in python - at least from some comments on the web, but it's clearly not working here. This might also have implications in conn_client (which calls itself) and recon_reader (which calls conn_client and is called by conn_client->ctrl_client). conn_client is easily modified, should we pass-through the exception in recon_reader and then just catch it in conn_client and reconnect? -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: pespin Gerrit-Comment-Date: Wed, 19 Jun 2019 15:44:22 + Gerrit-HasComments: No Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 ) Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. Patch Set 1: (1 comment) https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py File scripts/osmo_trap2cgi.py: https://gerrit.osmocom.org/#/c/14545/1/scripts/osmo_trap2cgi.py@211 PS1, Line 211: await ctrl_client(proxy, reader, writer) I don't know how this framework works, but are you sure keeping ctrl_client in a while True loop is fine? For instance this function conn_client looks like will block always here. Just to make sure. -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin Gerrit-Comment-Date: Wed, 19 Jun 2019 15:43:58 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
Change in ...osmo-python-tests[master]: osmo_trap2cgi.py: Don't recurse in ctrl_client()
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 Change subject: osmo_trap2cgi.py: Don't recurse in ctrl_client() .. osmo_trap2cgi.py: Don't recurse in ctrl_client() Use a loop instead. Without it the script will eventually crash with a RecursionError. File "/usr/bin/osmo_trap2cgi.py", line 211, in conn_client await ctrl_client(proxy, reader, writer) File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) [...] File "/usr/bin/osmo_trap2cgi.py", line 202, in ctrl_client proxy.dispatch(wr, data) File "/usr/bin/osmo_trap2cgi.py", line 201, in ctrl_client [...] RecursionError: maximum recursion depth exceeded in comparison Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Related: SYS#4399 --- M scripts/osmo_trap2cgi.py 1 file changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/45/14545/1 diff --git a/scripts/osmo_trap2cgi.py b/scripts/osmo_trap2cgi.py index ad66e7b..8aa7649 100755 --- a/scripts/osmo_trap2cgi.py +++ b/scripts/osmo_trap2cgi.py @@ -194,12 +194,12 @@ async def ctrl_client(proxy, rd, wr): """ -Recursively read CTRL stream and handle selected messages. +Read CTRL stream and handle selected messages. """ -header = await recon_reader(proxy, rd, 4) -data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) -proxy.dispatch(wr, data) -await ctrl_client(proxy, rd, wr) +while True: +header = await recon_reader(proxy, rd, 4) +data = await recon_reader(proxy, rd, get_ctrl_len(proxy, header)) +proxy.dispatch(wr, data) async def conn_client(proxy): """ -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/14545 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: Ic909e371771f3056cb87e18793fd4225ffb90a2c Gerrit-Change-Number: 14545 Gerrit-PatchSet: 1 Gerrit-Owner: daniel Gerrit-MessageType: newchange