github procrastinate-org/procrastinate 0.30.0rc1
0.30.0rc1: A preview of breaking changes to come in #753

pre-release12 months ago

Migrations

None

Breaking changes

#753 brings import changes to the way sync and async work in procrastinate.

  • We've tried to remove some place where we "seemlessly" executed async code from sync calls because it wasn't seemless at all. Most of the sync methods that are just wrappers over async methods with syntax sugar to avoid having to run the even loop yourself, have been removed. This means all the sync methods of JobManager and App.check_connection. The AsyncConnector subclasses don't support being called via sync methods anymore. The way to fix this if you were using it is to use async code when interacting with Procrastinate's systems (so from sync code, either use asyncio.run or asgiref.sync.async_to_sync and call async methods).

  • The remaining methods on the sync API are:

    • Task.defer which is implemented as a synchronous function and will stay that way
    • App.run_worker has been reimplemented on top of App.run_worker_async. It uses its own event loop. This is probably the only case where it makes sense that Procrastinate provides a sync shortcut because it's a long-lived call. For all other async methods, trying to handle the event loop in Procrastinate is likely to cause more problem than it solves, whereas the caller is in a much better solution to solve it the right way as they're in control of the process they run the code from.
    • Providing your synchronous tasks for Procrastinate to run has a much better support now, thanks to
      asgiref.sync.sync_to_async.

    Those are the 3 only part of the synchronous Procrastinate API that are left. We don't plan to remove them, and they're enough to get almost all of the nice things of procrastinate in your sync project. If Procrastinate doesn't drastically change in the future, there's no reason we'd want to add more sync stuff.

  • Due to dropping Click in favor of argparse for async reasons, some commands that accepted parameter in any order now don't. It should be mainly mixing positional CLI args and flags: you used to be able to do procrastinate defer x --unknown {} and now you'll have to put all positional args first: procrastinate defer x {} --unknown. I can't guarantee that there won't be other subtle breaks around this (e.g. environment variable support). That said, if you discover a change, feel free to open a ticket, if it's easily fixable, we might fix it.

  • You may have issues if you call App.open right after creating the app.

    • Ideally, open the app only in the context where you know you'll be using it (in a given process, you'll likely either use the sync app or the async app, not both, so try to open only the one you'll use)
    • Ideally, try to open the app at the start of the process and close it at the end. It might not be easy to find the exact right place to do so, but we'll try to give some advice. For Django, for example, that might be an AppConfig.ready() and atexit (from the standard lib). YMMV.
    • For app configured with a sync connectors, use app.open() and app.close() (or with app.open()). With an async connector, use await app.open_async() and await app.close_async() or async with app.open_async(). Calling app.open() on an async app is not supported anymore.

Dependencies

  • Lock file maintenance (#856)
  • Lock file maintenance (#853)
  • Bump urllib3 from 2.0.6 to 2.0.7 (#851)
  • Lock file maintenance (#850)
  • Update Deps with major upgrades to v2 (major) (#847)
  • Lock file maintenance (#848)
  • [pre-commit.ci] pre-commit autoupdate (#849)

Kudos:

@dependabot, @dependabot[bot], @ewjoachim, @pre-commit-ci, @pre-commit-ci[bot], @renovate and @renovate[bot]

Don't miss a new procrastinate release

NewReleases is sending notifications on new releases.