Replies: 4 comments 17 replies
-
Re skulpt. Unfortunately I think that'll take a long time. My main problem with async await in Python for anvil is that you always have to block somewhere to run the event loop. Async calls then do their thing. But I've never seen async code that gives a callback and says 'give me the result when you're done, and I'll continue doing stuff until then'. It's more 'give me the result when you're done and I guess I'll just wait patiently until then'. I'd love to see an example of the former. But that seems to be more of a threading pattern. The tasks in the event loop are free to hand over to each other while they await. But you always seem to have to wait for all tasks to complete before moving on in your code. So I've never quite gotten my head around how it would look in Anvil. I haven't done that much serious python async await stuff though. I was never fully happy with the API so I'll have a think about your suggestions. I was quite influenced by the JavaScript api. I did think about delay=0. @meatballs did you use either of these in your code yet? How do we feel about the rest of the API? |
Beta Was this translation helpful? Give feedback.
-
@s-cork from the other comment thread:
Whoa, this is not what I expected. So that means a Timer tick event could fire (and execute client code) while a server function is running? But user input via the UI is blocked during a server call (even |
Beta Was this translation helpful? Give feedback.
-
(In reference to: #70 (reply in thread))
Ok, I think what must have happened is that I was expecting the button to
trigger a server call with the spinner. But the silent server call was
still running. So the button click function ran, but it stopped at the
"await server.call" line until the silent server call was finished. If
that's right (I won't be able to test it for a bit), I may make an Anvil
feature request to start the spinner right away, even if the server call
hasn't started (been sent?) yet due to a backup in the server queue.
…On Wed, Apr 27, 2022, 8:37 AM stu ***@***.***> wrote:
not that I know of
—
Reply to this email directly, view it on GitHub
<#70 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB63GLAFAQOHDPCR5XWJSPDVHE7H3ANCNFSM5UMMGUDQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
For what it's worth, now that I understand that ordinary |
Beta Was this translation helpful? Give feedback.
-
With reference to #52, I'd also love to use async server calls in a production-ish app. I could just copy the code, but if I could spend a similar amount of time helping it along to become part of anvil-extras, I'd rather do that.
The thing that strikes me as the most likely obstacle is that the API seems tentative in places. (For example, the docs note how
Interval
works different from an Anvil Timer component in a way that could trip people up.)Here are some suggested changes for discussion--but no need to respond to any of these. Rather I presume each of them has already been rejected for good reason. But feel free to adopt or discuss further if any of them do seem helpful:
call_server_async
toserver_call_async
to better mirror Anvil's (and kompot's) API.Interval
so that settingdelay=0
stops it (the same asdelay=None
).Interval
'sdelay
attribute to `period'.Timeout
toDelay
(and rename its attributedelay
toperiod
). (Withperiod=0
, it should execute without delay.)clear
methods tostop
.Also, more generally, I may not know enough to ask this question intelligibly, but would it be better/possible to implement async stuff in Skulpt directly, like using the async/await keywords? (Really, my level of understanding on this is just, "I hear people in Python podcasts talking about async/await, so maybe that's relevant.") In other words, to implement the relevant Python syntax/standard library rather than adding a new package? But I guess that may not be ideal because of some differences between JS and Python that I don't fully understand?
Another way I might be able to contribute is trying to add cases to the existing tests? Would that be helpful?
Beta Was this translation helpful? Give feedback.
All reactions