Skip to content

letsdiscodev/python-dqlite-wire

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

197 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dqlite-wire

Pure Python wire protocol implementation for dqlite, Canonical's distributed SQLite.

Installation

pip install dqlite-wire

Usage

from dqlitewire import MessageEncoder, MessageDecoder
from dqlitewire.messages import LeaderRequest, ClientRequest

# Encode a message
encoder = MessageEncoder()
data = encoder.encode(LeaderRequest())

# Decode a message
decoder = MessageDecoder()
decoder.feed(data)
message = decoder.decode()

Thread-safety

ReadBuffer, WriteBuffer, MessageEncoder, and MessageDecoder are not thread-safe. Each instance must be owned by a single thread or a single asyncio coroutine at a time. This matches Go's driver.Conn contract from go-dqlite.

Concurrent use of a single instance from multiple threads produces silent data corruption — not exceptions. The is_poisoned mechanism catches torn state from signal delivery during single-owner execution, but it cannot detect lost-update races between concurrent threads. Fuzz testing reliably reproduces both duplicate message delivery and corrupt (garbage) message bytes with no exception surfacing.

If you need concurrent access, wrap every call site in an asyncio.Lock or threading.Lock at the layer that owns the socket and decoder.

Protocol Reference

Based on the dqlite wire protocol specification.

Development

See DEVELOPMENT.md for setup and contribution guidelines.

License

MIT

About

Pure Python wire protocol implementation for dqlite

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages