Skip to content

SAConnection twophase methods are broken #886

Open
@gistart

Description

@gistart

Describe the bug

  1. begin_twophase() is not a context manager
  2. recover_twophase() is broken
  3. rollback_prepared() is broken

To Reproduce

just use these methods)

Expected behavior

  1. begin_twophase() behaves as a context manager, using commit_prepared() at the end OR docs changed to reflect current implementation
  2. does not crash on accessing ResultProxy
  3. does not crash on string formatting

Logs/tracebacks

1. begin_context() is not a context

According to docs: https://aiopg.readthedocs.io/en/stable/sa.html#aiopg.sa.SAConnection.begin_twophase

coroutine async-with begin_twophase(xid=None)

but in reality:

    async with conn.begin_twophase() as transaction:
AttributeError: __aenter__

2. recover_twophase() is broken

result is not awaited:

  File "/Users/ovmikhaylov/work/aiopg/aiopg/sa/connection.py", line 363, in recover_twophase
    return [row[0] for row in result]
TypeError: 'ResultProxy' object is not iterable

3. rollback_prepared() is broken

Due to error in f-string:

  File "/Users/ovmikhaylov/work/aiopg/aiopg/sa/connection.py", line 368, in rollback_prepared
    await self.execute(f"ROLLBACK PREPARED {xid:!r}")
ValueError: Invalid format specifier

Python Version

3.10

aiopg Version

1.3.3

OS

Darwin gmbp.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Oct 12 18:33:42 PDT 2021; root:xnu-7195.141.8~1/RELEASE_X86_64 x86_64

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions