H
H
HgeN2014-09-28 18:51:46
Python
HgeN, 2014-09-28 18:51:46

How to organize custom scripting in a python application?

There is a need to implement the ability to write custom logic handlers. It is understood that simple users who are not familiar with programming will have to write handlers.
At the same time, the application itself is asynchronous (tornado) and the user script must not be allowed to block the main thread of execution. I looked in the direction of alternative interpreters and greenlets, but did not find good examples of the implementation of such a task.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Chistyakov, 2014-09-28
@HgeN

Based on the requirement that the Tornado state machine cannot be blocked, the conclusion follows that it is necessary to create a pool of user script handlers (on whatever they are) and manage this pool. The scheduler can work in the simplest way - N workers are created at startup, then, when a task is assigned to a worker, it is marked as busy. When the user script has completed, the worker is released. If all the workers are busy, user tasks are queued, by
the way, if from the very beginning we take a system that implements queues - RabbitMQ, for example, then everything becomes even better - instead of a pool of handlers, a pool of consumers is created in the application, respectively. queues in RabbitMQ, moreover, consumers can be added dynamically without reloading any tornado server configs.
But on what the user scripts themselves will be written - it doesn’t matter at all, at least in VB.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question