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

Refactor Action constructor to build its own database descriptor #8

Open
magsol opened this issue May 19, 2011 · 4 comments
Open

Refactor Action constructor to build its own database descriptor #8

magsol opened this issue May 19, 2011 · 4 comments
Assignees

Comments

@magsol
Copy link
Owner

magsol commented May 19, 2011

When an Action constructor is invoked, it should build (from scratch) and maintain its own connection to the database. This will furthermore ensure that child processes do not accidentally inherit the parent's database descriptor.

@ghost ghost assigned magsol May 19, 2011
@magsol
Copy link
Owner Author

magsol commented May 20, 2011

In reference to Issue #6, have the construction of each Action performed as late in execution as possible, namely when a child process is in control.

@magsol
Copy link
Owner Author

magsol commented May 28, 2011

This issue is on hold: part of the problem is that the Actions need to be constructed in order to use their getNextAttempt() method to determine when to fire them, but doing so also initializes a database connection (if it's in the constructor) before the child process has been spawned for the Action, thereby creating the problem this ticket was meant to address.

For the time being, the fix is to add the following line to the start of every Action's run() method:

if (!isset($this->db)) { $this->db = Storage::getDatabase(); }

@magsol
Copy link
Owner Author

magsol commented Jun 9, 2011

Current milestone will likely not support a fix to this; removing this from the current milestone.

@magsol
Copy link
Owner Author

magsol commented Jun 15, 2011

This needs to be refactored in such a way that the database descriptor is only created when the action fires, since the action is assigned a new child process every time it runs. With the descriptor built in the constructor, it would only work once until the second time the action is called and spun off into a child process.

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

No branches or pull requests

1 participant