Skip to content

Implement shared memory #4

@pietroalbini

Description

@pietroalbini

Because the botogram runner works in a multiprocessing environment, bot developers haven't any native way (excluding external services) to share data between the different workers.

Shared memory provides a simple and reliable way to do that. The API is simple, and allows synchronization of any picklable object. It will also implement a way to initialize shared memories.

@bot.init_shared_memory
def init_shared(shared):
    shared["messages"] = 0

@botogram.pass_shared
@bot.process_message
def process_message(shared, chat, message):
    shared["messages"] += 1
  • Implement the basic structure of the shared memory (not in the runner)
  • Implement shared memory in the runner
  • Fix shared memory not working on Windows (issue Cannot start shared-memory branch on Windows #3)
  • Implement init_shared_memory
  • Document the whole thing

This issue tracks the progress for this feature.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions