Skip to content

Commit

Permalink
Change comments in the README's code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Éric Lemoine committed Dec 17, 2020
1 parent 65ca4ac commit 9929ee1
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ Here's an example:
with open("myfile", "w") as f:
f.write(str(a + b))
# Open the connection to the database
with app.open():
# Launch a job
# (make sure that the `procrastinate` schema was applied
# _once_ before)
sum.defer(a=3, b=5)
# Somewhere in your program (actually, often a different
# program than the one deferring jobs for execution), run a worker
# Somewhere in your program, run a worker (actually, it's often a
# different program than the one deferring jobs for execution)
app.run_worker(queues=["sums"])
The worker will run the job, which will create a text file
Expand Down Expand Up @@ -95,21 +92,17 @@ Lastly, you can use Procrastinate asynchronously too:
# Make an app in your code
app = procrastinate.App(connector=procrastinate.AiopgConnector())
# Define asynchronous tasks using coroutine functions
# Define tasks using coroutine functions
@app.task(queue="sums")
async def sum(a, b):
await asyncio.sleep(a + b)
# Open the connection to the database `async`,
async with app.open_async():
# Launch a job asynchronously
# (make sure that the `procrastinate` schema was applied
# _once_ before)
# Launch a job
await sum.defer_async(a=3, b=5)
# Somewhere in your program (actually, often a different
# program than the one defering jobs for execution), run a
# worker asynchronously
# Somewhere in your program, run a worker (actually, it's often a
# different program than the one deferring jobs for execution)
await app.run_worker_async(queues=["sums"])
There are quite a few interesting features that Procrastinate adds to the mix.
Expand Down

0 comments on commit 9929ee1

Please sign in to comment.