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

Way less globals #37

Merged
merged 14 commits into from
Oct 27, 2014
Merged

Way less globals #37

merged 14 commits into from
Oct 27, 2014

Conversation

ionelmc
Copy link
Owner

@ionelmc ionelmc commented Oct 26, 2014

Lets see if the commit comments appear here

@ionelmc
Copy link
Owner Author

ionelmc commented Oct 26, 2014

I think I've addressed all your comments.

About the merge, my plan is to re-integrate all the small changes from master and then do a "merge --strategy=ours" (discard everything from master). It's way easier that way.

After that I'm going to rebase the remaining PRs on top this.

@ionelmc
Copy link
Owner Author

ionelmc commented Oct 26, 2014

I can squash everything but then we lose all your comments. Ideally you'd look here https://github.com/ionelmc/python-manhole/pull/37/files (it's an equivalent of a squash).

@nirs
Copy link
Collaborator

nirs commented Oct 26, 2014

@nirs
Copy link
Collaborator

nirs commented Oct 26, 2014

Anway, what I do when I want to keep versions, is to create a new branch for each version, for example, see https://github.com/nirs/sanlock - branchs python-events, python-events-1, ...

@@ -156,8 +135,8 @@ class Manhole(_ORIGINAL_THREAD):
daemon_connection (bool): The connection thread is daemonic (dies on app exit). Default: ``False``.
"""

def __init__(self, sigmask, start_timeout, bind_delay=None, locals=None, daemon_connection=False):
super(Manhole, self).__init__()
def __init__(self, get_socket, sigmask, start_timeout, bind_delay=None, locals=None, daemon_connection=False):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to have get_socket as an argument? Since get_socket is static now, it should simply be a module function - any reason to keep it elsewhere?

Or simply use _MANHOLE.get_socket()

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's not assigned to _MANHOLE when get_socket needs to be called. This can be removed if we change how the assignment is done ( 4503f8a#commitcomment-8307134 )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - doing nothing in init and moving all side effects to Manhole.install() will fix that.

@ionelmc
Copy link
Owner Author

ionelmc commented Oct 26, 2014

That makes sense if you want to maintain multiple versions at once. You really want version branches?

else:
self.destination.write(full_message)
except: # pylint: disable=W0702
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line or two after the class will make it easier to read and pep8 happier.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@nirs
Copy link
Collaborator

nirs commented Oct 26, 2014

Reviewing the the pull request diffs is fine for me.

if _SHOULD_RESTART:
_INST.start()
_LOG.configure(verbose, verbose_destination)
_MANHOLE.configure(**kwargs) # Threads might be started here
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not solve the dependencies issue.

I think we need this api for the manhole:

  • __init__ - keep configuration, no side effects
  • install - patching fork, register signal handlers
  • activate - bind socket, start thread

In oneshot mode, the mahole is installed but never activated
in activate_on mode, the manhole is installed but activate only when receiving the activation signal
in default mode, the manhole is installed and activated immediately

So when manhole thread run, _MANHOLE.get_socket() is available.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ideally it would be like that. But for now I think it works fine like this. I think we should refactor this later.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, lets minimize the changes in this patch.

@ionelmc ionelmc merged commit 7a5ae48 into master Oct 27, 2014
@ionelmc ionelmc deleted the way-less-globals branch October 27, 2014 22:47
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

Successfully merging this pull request may close these issues.

None yet

2 participants