judge0 / judge0/judge0-python

Add sync and async client APIs

Open
#50 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
35
Forks
6
Avg merge
28m
Merged PRs (30d)
2

Description

Is your feature request related to a problem? Please describe.

The SDK currently exposes only a synchronous Client built on httpx.Client. That blocks use from asyncio applications, AI agents, and other concurrent callers without wrapping blocking I/O in a thread pool.

Issue #33 already moved the HTTP layer from requests to httpx. httpx can serve both sync and async traffic, but the public API still has no async client, no async methods, and no httpx.AsyncClient path.

Describe the solution you'd like

Expose paired synchronous and asynchronous client APIs with the same Judge0 operations (about, config, languages, statuses, create/get submission, batch create/get).

Keep the existing sync Client as the default for scripts and notebooks. Add an async counterpart (for example AsyncClient) with async methods and an async HTTP client.

Public flavor classes (Judge0CloudCE, RapidJudge0CE, ATDJudge0CE, Extra CE variants, and any later flavors) should remain usable in both modes, or have explicit async counterparts, so authentication and endpoints stay consistent.

Callers should be able to inject a custom HTTP client when they need proxies, timeouts, or tests.

Describe alternatives you've considered

  • Keep only the sync client and document asyncio.to_thread. That works for a few calls, but it does not share connection pools well and is a poor default for high-concurrency agents.
  • Add async methods on the same class. Mixed sync/async on one object is easy to misuse (event-loop blocking, lifecycle of two HTTP clients).
  • Stay on httpx for both Client and AsyncClient. This is the smallest change after #33.
  • Move the HTTP layer to HTTPX2 (httpx2.Client / httpx2.AsyncClient). HTTPX2 is a maintained continuation of HTTPX with first-class sync and async APIs. That is a larger dependency change and needs a compatibility review.

Additional context

Related work:

  • Closed issue #33: switch from requests to httpx.
  • pydantic/httpx2: HTTP client with both sync and async APIs.
  • openai-python httpx2.md: how a Python SDK exposes paired OpenAI / AsyncOpenAI clients on HTTPX2, including default HTTP clients and custom-client injection.

This issue does not decide to adopt HTTPX2. Use those documents as design references when choosing the public client split and the HTTP transport.

Contributor guide

Open the contributing guide

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.

Research direction

Start with the existing synchronous Client and public flavor classes, then read issue #33 and the linked HTTPX2 and OpenAI design references. Define the paired sync and async API surface for all listed Judge0 operations, authentication, endpoints, and custom HTTP-client injection; done means both modes are usable without blocking async callers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.