Async state and message handler

Open
#1,005 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 9 days

Nobody has claimed this yet.

  • #1411 by @Nikhil172913832 — closed without merging

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
testing-qa

Research direction

Start by locating the state_handler and message_handler entry points and reading how synchronous functions are currently invoked. Compare the requirements of asyncio, trio, and curio, including ContextVar and thread implications; done means the supported asynchronous handlers work without breaking existing synchronous handlers and are covered by tests.

Written by the indexing model from the issue text.

Description

area:core difficulty:medium type:feature
Have you read the Contributing Guidelines on issues?
Description

Original suggestion by Val on Slack

To allow the state_handler and message_handler functions to handle asynchronous functions.

Motivation

These two functions are used to interface with code outside of Pact Python to setup/teardown states and generate messages. Especially in the case of the state setup and teardown, a common pattern would be to make a number of calls to (mocked or not) databases or other services to ensure they are in a particular state. These requests can be significantly sped up by running them in parallel, such as with an asyncio.gather call or using a task group.

Have you tried building it?

Not yet, but I will first open this issue and ask for anyone with specific examples to work towards.

While asynchronous function bring a number of advantages, they can also bring some complications. In particular:

  • There are a number of underlying runtimes: asyncio, trio, curio. If possible, it would be ideal to support all of these.
  • The use of threads has implications for ContextVar (if used)
Self-service
  • I'd be willing to contribute this feature to Pact Python myself.
Dominant language
Python
Stars
689
Forks
147
Avg merge
8d 11h
Merged PRs (30d)
27

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pact-foundation/pact-python

All issues in pact-foundation/pact-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.