def __init__(self, menuitem, args, kwargs): self.worker = ThreadedWorkerCore(menuitem, args, kwargs) self.menuitem = menuitem # for debugging # self.lock prevents changes to the worker at inauspicious # times. self.lock = lock.SLock() Worker.__init__(self) self.worker.toplevel = self.toplevel
def __init__(self, when, what, where, min_contour, max_contour, levels, filter): self.what = what.clone() # Should be clones, or not? self.where = where self.min_contour = min_contour self.max_contour = max_contour self.levels = levels self.lock = lock.SLock() self.contourmaphidden = False self.contourmap_user_hide = 0 displaymethods.MeshDisplayMethod.__init__(self, filter, when)
def __init__(self, *args, **kwargs): OOFMenuItem.__init__(*((self, ) + args), **kwargs) if not 'cli_only' in self.options: self.options['cli_only'] = 0 if not 'gui_only' in self.options: self.options['gui_only'] = 0 if not 'no_log' in self.options: self.options['no_log'] = 0 ## if not 'disabled' in self.options: ## self.options['disabled'] = 0 if not 'help_menu' in self.options: self.options['help_menu'] = 0 self.logbook = [] self.loggers = [] # additional logging functions self._loghalted = 0 self._logchanged = 0 self.loglock = lock.SLock() self.quiet = 0
def __init__(self, filename, mode, openfile): self.filename = filename self.file = None self.openfile = openfile # fn that actually opens the file # _streamsLock has always been aquired before __init__ is called. _allStreams[filename] = self self.referents = [] # all OutputStreams using this BaseOutputStream # lastOutput and lastargs are used to decide whether or not to # write the header info in the data file. It's not written if # the output and its args are the same as they were for the # previous write. self.lastOutput = None self.lastargs = None self.seplast = True # was the last thing written a separator? self.nOpen = 0 # net number of times this has been opened self.everOpened = False # has this been opened in this oof2 session? self.lock = lock.SLock() # controls access by OutputStreams self.mode = mode self.rewound = False self.appending = False
def __init__(self): self.listofminithreads = [] self.lock = lock.SLock()
def __init__(self): self.buf = [] ## list of stored commands self.destroyflag = False # buffer has been destroyed self.lock = lock.SLock()
# frame in which the exception occurred, and this can prevent # garbage collection. TODO: One can imagine circumstances in # which this isn't the right thing to do, but those circumstances # should probably assign a new excepthook function. sys.exc_clear() def __cmp__(self, other): return cmp(id(self), id(other)) #=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=# from ooflib.SWIG.common import threadstate _exceptStacks = {} _exceptLock = lock.SLock() def assign_excepthook(newhook=sys.__excepthook__): # debug.fmsg("adding hook", id(newhook)) _exceptLock.acquire() threadno = threadstate.findThreadNumber() try: hookstack = _exceptStacks[threadno] except KeyError: hookstack = _exceptStacks[threadno] = [] hookstack.append(newhook) _exceptLock.release() return newhook
# [email protected]. ## Store and retrieve named sets of analysis parameters from ooflib.SWIG.common import lock from ooflib.common import debug from ooflib.common import registeredclass from ooflib.common import utils from ooflib.common.IO import parameter from ooflib.common.IO import xmlmenudump from ooflib.engine.IO import analyze from ooflib.engine.IO import scheduledoutput from ooflib.engine.IO import outputdestination _namedAnalyses = utils.OrderedDict() namelock = lock.SLock() class _nameResolver(object): # Callable object for creating a unique name for a bulk or # boundary analysis. def __init__(self, defaultname): self.defaultname = defaultname def __call__(self, param, name): if param.automatic(): basename = self.defaultname else: basename = name return utils.uniqueName(basename, _namedAnalyses.keys())
def __init__(self): debug.mainthreadTest() self.listofgtkbars = [] self.makeMenus() # Sets self.menu. # SubWindow init sets self.gtk and self.mainbox. subWindow.SubWindow.__init__(self, title="%s Activity Viewer" % subWindow.oofname(), menu=self.menu) self.gtk.connect('destroy', self.closeCB) self.gtk.set_default_size(400, 300) # Area at the top containing the editor widget for the line self.control_area = gtk.HBox() # editor widget goes in here self.mainbox.pack_start(self.control_area, expand=0, fill=0, padding=2) ## Dismiss All bars self.dismissall = gtkutils.StockButton(gtk.STOCK_CANCEL, "Dismiss All") gtklogger.setWidgetName(self.dismissall, "DismissAll") gtklogger.connect(self.dismissall, "clicked", self.dismissAllCB) self.control_area.pack_start(self.dismissall, expand=1, fill=0, padding=2) ## stop-all-threads self.stopall = gtkutils.StockButton(gtk.STOCK_STOP, "Stop All") gtklogger.setWidgetName(self.stopall, "StopAll") gtklogger.connect(self.stopall, "clicked", self.stopAll) self.control_area.pack_start(self.stopall, expand=1, fill=0, padding=2) # Create a scrolled window to pack the bars into scrolled_window = gtk.ScrolledWindow() scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) gtklogger.logScrollBars(scrolled_window, "Scroll") self.mainbox.pack_start(scrolled_window, expand=1, fill=1, padding=2) ## Create VBox where the progressbars can live happily ever after self.bars_play_area = gtk.VBox() # homogeneous=True? scrolled_window.add_with_viewport(self.bars_play_area) self.proglock = lock.SLock() self.proglock.acquire() try: for worker in threadmanager.threadManager.allWorkers(): worker.threadstate.acquireProgressLock() try: progressnames = worker.threadstate.getProgressNames() for pname in progressnames: try: prgrss = worker.threadstate.findProgress(pname) except ooferror.ErrNoProgress: # Progress object already finished pass else: if prgrss.started(): self.installBar(prgrss) finally: worker.threadstate.releaseProgressLock() finally: self.proglock.release() self.gtk.show_all() self.sensitizeButtons()
# list, return it. If it is, append "<number>" to it, where 'number' # is chosen so that the result is unique. # If the given name is an AutomaticName instance, then an # AutomaticName instance is returned. # The list of names passed to uniqueName is almost always a global # list, and so in a threaded environment we need to prevent # simultaneous uniqueName calls with the same name list. Since the # calls are quick and not done in time sensitive situations, we put a # single mutex lock inside uniqueName, instead of requiring all # callers to implement their own lock. import re _uniqueNameLock = lock.SLock() def uniqueName(name, othernames, exclude=None): _uniqueNameLock.acquire() others = othernames[:] try: if exclude is not None: try: others.remove(exclude) except ValueError: pass if name not in others: return name from ooflib.common.IO import automatic # delayed to avoid import loop auto = isinstance(name, automatic.AutomaticName)
def __init__(self): ## Keep list of workers in order to quit properly. At exit ## time, the ThreadManager loops over the running workers and ## forces them to stop and join. self.listofworkers = [] self.lock = lock.SLock()
def __init__(self): # Lock to protect potentially-shared data. It's an SLock # because getWindow can be called on the main thread. self.lock = lock.SLock() self.windows = [] self.count = 0
def __init__(self): self.layers = [] # Displaymethod objects, from bottom to top. self.layerChangeTime = timestamp.TimeStamp() self.sorted = True # This lock just protects the local list. self.lock = lock.SLock()
def cleanUp(): global shuttingdown shuttingdown = True switchboard.requestCallbackMain("shutdown", cleanUp) #=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=# # BaseOutputStream does the work for OutputStream, which writes Output # data to a file. More than one OutputStream can write to the same # file, which they do by sharing a single BaseOutputStream. _allStreams = utils.OrderedDict() # All BaseOutputStreams, keyed by filename _streamsLock = lock.SLock() # Controls access to _allStreams class BaseOutputStream(object): def __init__(self, filename, mode, openfile): self.filename = filename self.file = None self.openfile = openfile # fn that actually opens the file # _streamsLock has always been aquired before __init__ is called. _allStreams[filename] = self self.referents = [] # all OutputStreams using this BaseOutputStream # lastOutput and lastargs are used to decide whether or not to # write the header info in the data file. It's not written if # the output and its args are the same as they were for the # previous write. self.lastOutput = None
# [email protected]. from ooflib.SWIG.common import lock from ooflib.SWIG.common import mpitools from ooflib.SWIG.common import ooferror from ooflib.common import debug from ooflib.common.IO import menuparser import errno, os, socket, sys, time, types # Local buffer and lock for doing socket-like communications between # threads on process zero. The buffer lock should be locked # (acquired) whenever the string is empty, so that attempts to read it # will block until there is data. _buffer_lock = lock.SLock() _buffer = "" _buffer_lock.acquire() SSH_TUNNEL = 0 # If boolean-true, then tunnel socket connections over ssh. # Device for listening to a socket, for use by remote "back end" # processes. Implements "getLine" and "getBytes". Starts an ssh # process to tunnel the socket from the remote machine to the local # machine. When a thread-safe concurrent implementation of MPI2 # exists, it should be used to replace this object. class SocketInput(menuparser.InputSource): # init requires the remote hostname and port. connection_attempt_limit = 1000000 buffer_size = 80
def __init__(self): self.pairs = [] self.lock = lock.SLock()