Skip to main content
iso8583sim.core.pool

MessagePool

Thread-safe object pool for ISO8583Message instances. Using a pool reduces object allocation overhead in high-throughput scenarios by reusing message objects instead of creating new ones.
pool = MessagePool(size=100)

Get a message from the pool

msg = pool.acquire(“0100”, {2: “4111111111111111”})

Process the message…

Return it to the pool when done

pool.release(msg)
Note: Messages returned to the pool have their fields cleared, so don’t hold references to field data after releasing. Initialize the message pool. Parameters
int
default:"100"
Maximum number of messages to keep in the pool

acquire()

Get a message from the pool or create a new one. Parameters
str
required
Message Type Indicator
dict[int, str]
required
Message fields dictionary
ISO8583Version
default:"ISO8583Version.V1987"
ISO8583 version
CardNetwork | None
default:"None"
Card network
str | None
default:"None"
Original raw message string
str | None
default:"None"
Message bitmap
ISO8583Message
An ISO8583Message instance (either recycled or new)

release()

Return a message to the pool for reuse. Parameters
ISO8583Message
required
The message to return to the pool
Note: The message’s fields are cleared to avoid holding references to old data.

clear()

Clear all messages from the pool.

size

Get current number of messages in the pool.

max_size

Get maximum pool size.

Functions

get_default_pool()

Get or create the default global message pool. Parameters
int
default:"100"
Pool size (only used on first call)
MessagePool
The default MessagePool instance

reset_default_pool()

Reset the default global pool.