On Thursday, February 11, 2016 at 5:42:26 AM UTC-8, fhivert wrote: > > Hi, > > Background: during my work on #13580 "Parallel map reduce on > SearchForest", I > hit a bug in the implementation of semaphore on MacOS. So I need some code > which on MacOS reproduce the behavior of BoundedSemaphore using a lock and > an > shared integer. > > Therefore I'm using the following code: > > class ActiveTaskCounterDarwin(object): > def __init__(self, task_number): > [...] > def task_start(self): > [...] > + a few other methods > > class ActiveTaskCounterOther(object): > def __init__(self, task_number) > [...] > def task_start(self): > [...] > + exactly the same lists of methods > > ActiveTaskCounter = (ActiveTaskCounterDarwin if sys.platform == 'darwin' > else ActiveTaskCounterOther) >
You could write class ActiveTaskCounterDarwin(ActiveTaskCounterOther). Then you don't need to replicate the list of other methods and you'd only need to override the methods in ActiveTaskCounterDarwin that are actually different [you could then name the other ActiveTaskCounter to emphasize that the "Darwin" version is basically a patched version for OSX]. That would at least reduce the number of doctests you need to replicate. It might then be doable to write the doctests in such a way that they test sys.platform and make sure they generate valid testable output all platforms (hence documenting the fact that you need to patch OSX behaviour) -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.