Skip to content

mbernier/temporal-python-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

temporal-python-demo

Comparing coding with Temporal and not Temporal

This script looks at a remote file for a specific string. If it is not there, an exception is thrown. The old-way,.py will handle this with try...except and Temporal will handle this gracefully with a backoff and retry.

old-way

This is a file that creates a string from concatenating the ouput of a series of functions when python old-way.py has been run. You will see that the first run throws an exception, because the remote file does not have the expected data. Then, on the second run, it will work because the file has been updated with the correct expected data.

temporal

This shows how to add Temporal python sdk to make the code durable. It will run the same methods, and uses a "potentially" async file to control whether the exception is thrown. Then, when the file gets updated, the code executes properly on a automatic retry from Temporal.

To run:

  1. Start your Temporal Server
  2. Run python worker.py

You will see that the first run throws an exception, because the remote file does not have the expected data. Then, on the second run, it will work because the file has been updated with the correct expected data.

The difference is that Temporal will automatically retry to run your workflow, with a small incremental backoff.

About

Comparing coding with Temporal and not Temporal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages