Live data from Hacker News

Temporal Python – A durable, distributed asyncio event loop (2023)

temporal.io

31–40 of 56 posts

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#31
I found out about Temporal 2+y ago now and were early adopters of their cloud. It's a bit of a paradigm shift when you start using it, but it is amazing at solving some types of problems in a very simple manner. There are some trade-offs, there always are, for us that was migrating long lived workflows. But the resulting simplicity and maintainability of the code has been great. One thing that was hard with Temporal was to "sell it" to business leaders because it's not a turn key solution, it's more like a piece of infra for engineers to build on top of. Kind of a higher level database-queue-workflow engine thing that simplifies work for engineers.

In short we were working on automating things like onboarding a new employee, which involves creating accounts for their saas apps, buying and shipping their device, email confirmations, satisfactions surveys etc. So a workflow could last up to 3 months with some fully automated systems, and some that required integrating with people (listening to jira event to trigger things, etc).

The error handling was the thing that sold me on Temporal, because things can break just about anywhere in unpredictable ways (not just code, can be process, employee quits during the onboarding, customer is out of licenses etc), so we need everything to be robust and be fixable by a person. With homegrown queue based systems or with BPEL it can be hard handling these situations (what if you need to roll back 3 steps?). With code you can use exceptions, write unit tests etc. We use the typescript sdk, promises made it very intuitive to code even some otherwise complicated scenarios (say event listeners etc).

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#32

Earlier quoted context omitted.

The Temporal server stores events and distributes tasks. There is a cloud offering or it can be self-hosted (with support for Cassandra, Postgres, MySQL, and SQLite persistence). This post focuses more on the Temporal Python SDK and not the general platform.

Could you or anyone else with experience with Temporal share how hard it is to self-host in practice? Like, is this more like Redis (self-hosting is trivial) or Supabase (nominally self-hostable, but if you try to do it you'll quickly realize it's a pain and the happy path is to use their hosted platform).

We offer a full guide to help here at https://docs.temporal.io/self-hosted-guide and many users of all sizes self-host Temporal. Having said that, it has challenges as does running any high-available production system. We offer cloud to ease this burden. You still run all your code/workers and you can end-to-end encrypt all data.

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#33
post #15

Anyone migrated from celery, with / without regrets?

We migrated from an in-house redis queuing system.

Temporal has its own way of doing things; there's rules about what you can and cant do in workflows, what has to live in activities, etc. Its generally quite easy to adapt existing code work with it. We use typescript.

The worst part for us has been error/anomaly handling. Workflows can sometimes hit a state where the status reads in progress and errors aren't reported anywhere except buried in the event log; which surfaces great in the UI but we still haven't figured out how to programmatically respond to this condition.

A good example is: we use a home-grown version of this [1] to proxy large payloads to S3. However, if those payloads get REALLY large, they can take some time to upload and download; and if that "some time" is longer than 5 seconds, the control plane will believe that the worker has died, it won't reschedule, and the workflow just sits in In Progress. There's always a beautiful error on the temporal dashboard, and we can manually terminate/retry, but the world just seems to die when this happens and we can't do error-level cleanup stuff like alert the user that the thing they were doing didn't finish.

Temporal is also challenging to get support for. Its new, open source, we don't pay for temporal cloud, and there's not a ton of resources or people using it. The documentation is quite bad (if you like 500,000 word pages, codegen'd library sites with no comments, and one example for each feature, you'll like their documentation). Given we run our own temporal cluster, we've also had pretty large challenges in the self-hosting world. We work through them, usually after deep-diving into the temporal server code itself, but there's startlingly little documentation on self-hosting, and even less community support.

Overall, we don't regret adopting it, but if we had a time machine we wouldn't do it again. I feel it makes a series of sacrifices in order to create a system that has extremely high standards for processing, like financial/bank/healthcare level stuff. But, not only are we not building that, but the system has never behaved in a way which makes me think I'd even want to use it if I worked in those industries. Obviously I feel like I'm the one in the wrong here, and I'm sure its just a matter of "we screwed up something somewhere", but that leads back to: bad documentation, no way to get professional support without being on their cloud, and a lack of community support.

[1] https://github.com/DataDog/temporal-large-payload-codec

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#35
post #3

As someone familiar with asyncio, I don't understand what this is or what it's for. What's an activity, workflow, or worker? > See the asyncio.sleep in there? That’s no normal local-process sleep; that’s a durable timer backed by Temporal. That's the normal asyncio.sleep. What does backed by Temporal mean? Reading further, it appears that Temporal is replacing the default asyncio event loop. I don't understand why ev…

The OP seems targeted at devs who are already quite familiar with Temporal and are interested in using the new Python exposure.

FWIW, as someone who has never previously encountered Temporal, and has only a vague sense of the specific problem set it's trying to tackle and architectural approach it has taken, I find the post to be fairly impenetrable.

I'd love to read a proper introduction to Temporal by way of Python (and probably also by comparison to Celery).

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#36
I love Temporal-- we use it at my company. It's very very good for our use case, but took a while to understand how to use it. We're still figuring things out (Workflow versioning is one thing we suck at still).

That said, I'm not sure why this post from 2023 was posted here today. There've been multiple updates to the Python SDK since this post.

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#37

I'd question if you really need to distribute work across machines. It's great this makes distributed systems easier to write but it's much better to reject the premise and avoid writing them in the first place.

Distributing the work across machines essentially comes for free with the ability to replay workflows from any step. You could run all of your worker processes on a single machine if it had enough capacity, but resuming a workflow on a different machine is transparent to your workloads assuming there's no local state.

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#38
post #3

As someone familiar with asyncio, I don't understand what this is or what it's for. What's an activity, workflow, or worker? > See the asyncio.sleep in there? That’s no normal local-process sleep; that’s a durable timer backed by Temporal. That's the normal asyncio.sleep. What does backed by Temporal mean? Reading further, it appears that Temporal is replacing the default asyncio event loop. I don't understand why ev…

I just had to write a Python program that handled multiple async events - from a serial line, and with a tkinter GUI. The only way to make it 'truly' async was to handle the runloops myself, and add a separate queue, onto which I push coroutines, for processing. UI events and Serial I/O events (involving passing of messages to update states on both sides) all have to be pushed through the same mechanism in order to g…

But that can indeed just be done with the standard `asyncio` loop. You run your GUI in a thread, run the `asyncio` event loop in its own thread, pass the `asyncio` loop messages with an `asyncio.Queue` and `asyncio.run_coroutine_threadsafe`, and then use `asyncio.to_thread` for the serial communication within the `asyncio` event loop.

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#39

I love Temporal-- we use it at my company. It's very very good for our use case, but took a while to understand how to use it. We're still figuring things out (Workflow versioning is one thing we suck at still). That said, I'm not sure why this post from 2023 was posted here today. There've been multiple updates to the Python SDK since this post.

> Workflow versioning is one thing we suck at still

well its not entirely your fault :) what practices have you adopted now that you have some experience with it?

lower down OP mentions that they got the link from a HN discussion on asyncio 2 days ago https://news.ycombinator.com/item?id=40287354 . i guess the upvotes are today's lucky 10,000 learning about it for the first time.

Re: Temporal Python – A durable, distributed asyncio event loop (2023)

#40
post #33
post #15

Anyone migrated from celery, with / without regrets?

We migrated from an in-house redis queuing system. Temporal has its own way of doing things; there's rules about what you can and cant do in workflows, what has to live in activities, etc. Its generally quite easy to adapt existing code work with it. We use typescript. The worst part for us has been error/anomaly handling. Workflows can sometimes hit a state where the status reads in progress and errors aren't report…

Would you not like it if you didn’t self host?

If I’m being honest if it is a big issue to self host but it’s value to developers is obvious and apparent why not pay?

Post reply on HN