You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwhisk.apache.org by OpenWhisk Team Slack <ra...@apache.org> on 2010/01/01 00:01:01 UTC

[slack-digest] [2022-07-17] #general

2022-07-17 01:51:31 UTC - Matt Welke: Does the Python runtime support async/await syntax via asyncio? I made a Python 3.10 version of the runtime, based on code in the repo openwhisk-runtime-python. I deployed an action based on it and it works fine if I use `def main(args):` in my action:
```{
  "greeting": "Hello stranger! 1 + 2 = 3. Here's a joke: An SEO expert walks into a bar, bars, pub, public house, Irish pub, tavern, bartender, beer, liquor, wine, alcohol, spirits...",
  "python_version": "3.10.5 (main, Jul 12 2022, 11:43:42) [GCC 8.3.0]"
}```
But doesn't work if I use `async def main(args):` (and I have `import asyncio` at the top of the file):
```{
  "code": "d7cf54b866121a2b5937a184bfae2640",
  "error": "There was an error processing your request."
}```
I also get a more detailed error message in the IBM Cloud Function logs:
```
Logs:

[
  "2022-07-17T01:46:57.046798Z    stderr: Traceback (most recent call last):",
  "2022-07-17T01:46:57.046882Z    stderr: File \"/action/1/bin/exec__.py\", line 69, in &lt;module&gt;",
  "2022-07-17T01:46:57.046889Z    stderr: out.write(json.dumps(res, ensure_ascii=False).encode('utf-8'))",
  "2022-07-17T01:46:57.046893Z    stderr: File \"/usr/local/lib/python3.10/json/__init__.py\", line 238, in dumps",
  "2022-07-17T01:46:57.046897Z    stderr: **kw).encode(obj)",
  "2022-07-17T01:46:57.046901Z    stderr: File \"/usr/local/lib/python3.10/json/encoder.py\", line 199, in encode",
  "2022-07-17T01:46:57.046904Z    stderr: chunks = self.iterencode(o, _one_shot=True)",
  "2022-07-17T01:46:57.046908Z    stderr: File \"/usr/local/lib/python3.10/json/encoder.py\", line 257, in iterencode",
  "2022-07-17T01:46:57.046912Z    stderr: return _iterencode(o, 0)",
  "2022-07-17T01:46:57.046916Z    stderr: File \"/usr/local/lib/python3.10/json/encoder.py\", line 179, in default",
  "2022-07-17T01:46:57.046919Z    stderr: raise TypeError(f'Object of type {o.__class__.__name__} '",
  "2022-07-17T01:46:57.046923Z    stderr: TypeError: Object of type coroutine is not JSON serializable",
  "2022-07-17T01:46:57.049569Z    stderr: sys:1: RuntimeWarning: coroutine 'main' was never awaited",
  "2022-07-17T01:46:57.059Z       stderr: The action did not initialize or run as expected. Log data might be missing."
]```
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1658022691139179
----