Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- engine = create_engine('postgresql://postgres:passw0rd@localhost:5432/mini_amazon')
- Session = sessionmaker(bind=engine, expire_on_commit=False)
- @contextmanager
- def session_scope():
- """
- Provide a transactional scope around a series of operations.
- """
- session = Session()
- try:
- yield session
- session.commit()
- except:
- session.rollback()
- raise
- finally:
- session.close()
- with session_scope() as session:
- while True:
- print('Waiting')
- order = session.query(models.Order).get(arrived_message.packageid)
- time.sleep(1)
- if order.status == 'packed':
- break
- order.status = 'loading'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement