Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickle Fysom object? #7

Open
firegrass opened this issue Apr 28, 2014 · 5 comments
Open

Pickle Fysom object? #7

firegrass opened this issue Apr 28, 2014 · 5 comments

Comments

@firegrass
Copy link

Would this be possible? Or it is too crazy?

It currently errors the below with if you try to pickle the example in the README.

pickle.PicklingError: Can't pickle <function startup at 0x7f4b8c4492a8>: it's not found as fysom.startup

  • I want to use the state machine over a series of web requests, and want to put it somewhere between requests.
@mriehl
Copy link
Owner

mriehl commented Apr 28, 2014

Can't you hold it in-memory between requests (this would be possible with twisted for example, as it's single threaded)?
Probably the most problematic part would be somehow marshalling the callbacks, if you use any. I'll have a closer look first thing tomorrow morning!

@mriehl mriehl self-assigned this Apr 28, 2014
@firegrass
Copy link
Author

I am using Flask, and ideally I'd like to be able to run it in a threaded or in a load balanced environment.

Perhaps it would be easier to recreate the state machine each time and restore the state from persistent storage (pickle/redis etc).

I'm hoping to achieve this to vastly improve my code for handling inbound Twillio calls :-D

@mriehl
Copy link
Owner

mriehl commented May 27, 2014

Is this still a problem for you? Serialization with callbacks doesn't look so good, due to the limitations when pickling functions or methods.

If you only use the current state of the state machine, it's easy to serialize it to a json-like string : it's basically the initial configuration, with initial set to fsm.current.

@amiraliakbari
Copy link

I suggest also supporting an standard format for (de)serialization, like .fsm file format. Specially, supporting creating the FSM object from an .fsm file would be a nice feature.

@mriehl
Copy link
Owner

mriehl commented Jun 18, 2014

Hi @amiraliakbari , thanks for that link. Exporting/importing from .fsm files sounds great. This would leave dealing with callbacks to the developer which is also ok from my perspective since it's not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants