Skip to content
This repository was archived by the owner on Apr 27, 2019. It is now read-only.

Some SQLAlchemy session cleanup#98

Merged
MrMarvin merged 2 commits intoStarryPy:developmentfrom
slitherrr:cleanup-sqlalchemy_sessions
Feb 11, 2014
Merged

Some SQLAlchemy session cleanup#98
MrMarvin merged 2 commits intoStarryPy:developmentfrom
slitherrr:cleanup-sqlalchemy_sessions

Conversation

@slitherrr
Copy link
Copy Markdown
Contributor

Rebuilt #93 on development, then split out the plugin part.

This is the session handling cleanup. The point is to abstract any session
management away from the endpoints are using the data, and to
initiate a session per transaction rather than leaving one session open
for the lifetime of the server (the latter was causing concurrency issues
when different factories were accessing the session).

Now actually pulling to development. Third time's the charm.

Rebuilt StarryPy#93 on development, then split out the plugin part.

This is the session handling cleanup. The point is to abstract any session
management away from the endpoints are using the data, and to
initiate a session per transaction rather than leaving one session open
for the lifetime of the server (the latter was causing concurrency issues
when different factories were accessing the session).
@MrMarvin
Copy link
Copy Markdown

Thank you very much! While testing your changes, I noticed that the plugin_store doesn't work anymore:

2014-02-10 20:57:11,882 - starrypy.plugin_manager.PluginManager - ERROR - Error in plugin <Plugin instance: new_player_greeter_plugin (version .1)> with function after_connect_response.
Traceback (most recent call last):
  File "/Users/marv/devel/StarryPy/plugin_manager.py", line 166, in do
    res = getattr(plugin, command, lambda _: True)(data)
  File "/Users/marv/devel/StarryPy/plugins/new_player_greeter_plugin/new_player_greeter_plugin.py", line 17, in after_connect_response
    my_storage = self.protocol.player.storage
  File "/Users/marv/devel/StarryPy/plugins/core/player_manager/manager.py", line 121, in __getattr__
    val = getattr(self.record, name)
  File "/Users/marv/devel/StarryPy/plugins/core/player_manager/manager.py", line 167, in storage
    caller = inspect.stack()[1][0].f_locals["self"].__class__.name
AttributeError: type object 'RecordWithAttachedSession' has no attribute 'name'

Can you do something about it?

@slitherrr
Copy link
Copy Markdown
Contributor Author

I'm not sure how I missed that, since the player greeter executes every time, but it wasn't giving me errors. Anyway, it's pretty easy to tell what the issue is. Shouldn't be hard to tape over, but the method that's throwing the error is a little too clever by half--it might be worthwhile to figure out how to pass that invisibly from the plugin rather than inspecting the stack. Anyway, I'll throw something together

@aawilson
Copy link
Copy Markdown

Ok, I've pushed up the requisite fix. Note that give_items() seems to be broken on development head right now (at least for me)--if that is the case for you, you can test this fix by commenting out the give_items and watching the greeter message.

MrMarvin pushed a commit that referenced this pull request Feb 11, 2014
@MrMarvin MrMarvin merged commit b855383 into StarryPy:development Feb 11, 2014
@MrMarvin
Copy link
Copy Markdown

Thank you very much! Its true that the inspection thing would break sooner or later, however thats something that works for now.
The give_item() method does work for me as expected. If you are experiencing something different, please feel free to open an issue on that.
btw: cute 🐑!

@slitherrr
Copy link
Copy Markdown
Contributor Author

Haha thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants