Skip to content

Commit

Permalink
chore: fixing some python code intention within README
Browse files Browse the repository at this point in the history
  • Loading branch information
tavallaie committed Sep 28, 2024
1 parent f0f4c4a commit c4e5b51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tembo-pgmq-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,17 @@ from tembo_pgmq_python.decorators import transaction
```python
@transaction
def transactional_operation(queue: PGMQueue, conn=None):
# Perform multiple queue operations within a transaction
queue.create_queue("transactional_queue", conn=conn)
queue.send("transactional_queue", {"message": "Hello, World!"}, conn=conn)
# Perform multiple queue operations within a transaction
queue.create_queue("transactional_queue", conn=conn)
queue.send("transactional_queue", {"message": "Hello, World!"}, conn=conn)

```
To execute the transaction:

```python
try:
transactional_operation(queue)
transactional_operation(queue)
except Exception as e:
print(f"Transaction failed: {e}")
print(f"Transaction failed: {e}")
```
In this example, the transactional_operation function is decorated with `@transaction`, ensuring all operations inside it are part of a single transaction. If an error occurs, the entire transaction is rolled back automatically.

0 comments on commit c4e5b51

Please sign in to comment.