Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python runner: move PANG message with topics after await result #1026

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions packages/python-runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,11 @@ async def run_instance(self, config, args):
asyncio.create_task(self.connect_input_stream(input_stream))

self.logger.info('Running instance...')
result = self.sequence.run(context, input_stream, *args)
result = self.sequence.run(context, input_stream, *args)

self.logger.info(f'Sending PANG')
monitoring = self.streams[CC.MONITORING]

# Sending Topics producer information to STH
produces_runtime = getattr(result, 'provides', None)

if produces_runtime == None:
produces = getattr(self.sequence, 'provides', None)
else:
produces = {}
produces['provides'] = produces_runtime
produces['contentType'] = getattr(result, 'content_type', None)
produces_json = json.dumps(produces)

if produces:
self.logger.info(f'Sending PANG with {produces}')
send_encoded_msg(monitoring, msg_codes.PANG, produces)

# Sending Topics consumer information to STH
consumes_runtime = getattr(result, 'requires', None)

Expand All @@ -246,6 +231,22 @@ async def run_instance(self, config, args):
result = Stream.read_from(result)
elif asyncio.iscoroutine(result):
result = await result

# Sending Topics producer information to STH
produces_runtime = getattr(result, 'provides', None)

if produces_runtime == None:
produces = getattr(self.sequence, 'provides', None)
else:
produces = {}
produces['provides'] = produces_runtime
produces['contentType'] = getattr(result, 'content_type', None)

if produces:
self.logger.info(f'Sending PANG with {produces}')
send_encoded_msg(monitoring, msg_codes.PANG, produces)


if result:
await self.forward_output_stream(result)
else:
Expand Down
Loading