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

Unable to use GitPython with Gevent. #1

Closed
daharon opened this issue Aug 18, 2011 · 9 comments
Closed

Unable to use GitPython with Gevent. #1

daharon opened this issue Aug 18, 2011 · 9 comments

Comments

@daharon
Copy link

daharon commented Aug 18, 2011

Hi, I'm trying to use GitPython in a gevent project and it would seem that I am unable to.
Here is an example of the problem.

Thanks,
Dan

@nova77
Copy link

nova77 commented Jun 11, 2012

This is a pretty serious issue. If anything there should be at least an option to use GitPython without async.

@Byron
Copy link
Member

Byron commented Jun 16, 2012

I agree ! Async was a bit of a silly idea, considering pythons GIL 'issue'. Even though one can workaround that with custom c-python modules, its somewhat difficult to distribute it properly.

In the last line, you see that it can't instantiate a lock, as it for some reason expects an argument. However, you ware free to plugin in your own LockCls by patching it with a wrapper which initializes the lock you have accordingly.

Doing so will not be trivial, as you need to get to async before gitpython does. Obviously, gitpython will initialize it, so you would have to add async to the sys.path yourself and import and patch it.

Removing async entirely from gitpython isn't that hard, but it would certainly take more than just a quick session, so monkeypatching it seems to be the best choice for now.

see
gitpython-developers/GitPython#63

ddunbar added a commit to ddunbar/async that referenced this issue Oct 22, 2012
…ntended conversion of Lock to a

staticmethod.
@ddunbar
Copy link
Contributor

ddunbar commented Oct 22, 2012

This bug isn't actually related to gevent at all, rather it is an inadvertent bug in how async.pool is using threading.Lock.

The problem is that threading.Lock is not actually a class (per 2.7), and therefore in pool.py in ThreadPool, this line:

LockCls = Lock

is actually creating an unbound method. Thus, in practice when async tries to instantiate the lock "class" object via:

    self._taskgraph_lock = self.LockCls()

what it is actually doing is calling threading.Lock() with a self argument (a ThreadPool install).

Trivial fix here:
ddunbar@b99158c

@abulte
Copy link

abulte commented Dec 6, 2012

The fix seems to do the trick for me, thanks!. Why hasn't it been PRed to main async repo?

@andyparsons
Copy link

+1 to get this fix pulled

@dmyung
Copy link

dmyung commented Dec 6, 2012

+1 requesting as well.
A related gitpython issue on this (gitpython-developers/GitPython#29 workaround was to downgrade versions - which is not possible for our gitpython needs.

@ddunbar ddunbar mentioned this issue Dec 7, 2012
@ddunbar
Copy link
Contributor

ddunbar commented Dec 7, 2012

I thought I did but I guess I just never sent it. Done!

@ml31415
Copy link

ml31415 commented May 7, 2013

+1 for getting the fix.

@Byron
Copy link
Member

Byron commented Nov 12, 2014

I believe this is fixed, latest version of async was pushed to pypi.

@Byron Byron closed this as completed Nov 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

8 participants