Package Biskit :: Package PVM :: Module pvm
[hide private]
[frames] | no frames]

Source Code for Module Biskit.PVM.pvm

  1  ## 
  2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
  3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
  4  ## 
  5  ## This program is free software; you can redistribute it and/or 
  6  ## modify it under the terms of the GNU General Public License as 
  7  ## published by the Free Software Foundation; either version 2 of the 
  8  ## License, or any later version. 
  9  ## 
 10  ## This program is distributed in the hope that it will be useful, 
 11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 13  ## General Public License for more details. 
 14  ## 
 15  ## You find a copy of the GNU General Public License in the file 
 16  ## license.txt along with this program; if not, write to the Free 
 17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 18  ## 
 19  ## 
 20  ## $Revision: 2.2 $ 
 21  ## last $Date: 2006/02/01 14:36:38 $ 
 22  ## last $Author: leckner $ 
 23   
 24  """ 
 25  PVM interface. 
 26  """ 
 27   
 28  ## MAX_RECURSION_LIMIT = 100000 
 29   
 30  from Biskit.PVM.pypvm_core import * 
 31   
 32  from cPickle import dumps # as _dumps 
 33  from cPickle import loads # as _loads 
 34   
 35   
 36  ## def dumps(object): 
 37  ##     import sys 
 38   
 39  ##     limit = sys.getrecursionlimit() 
 40   
 41  ##     while limit < MAX_RECURSION_LIMIT: 
 42   
 43  ##         try: 
 44  ##             s = _dumps(object) 
 45   
 46  ##             o = _loads(s) 
 47   
 48  ##             if not type(o) == type(object): 
 49  ##                 print 'dumps: inconsistency; %s, %s' % \ 
 50  ##                       (`type(o)`, `type(object)`) 
 51   
 52  ##             return s 
 53   
 54  ##         except RuntimeError: 
 55  ##             limit += 1000 
 56  ##             sys.setrecursionlimit(limit) 
 57   
 58  ##     raise RuntimeError, "Maximum recursion depth exceeded." 
 59   
 60  ## def loads(object): 
 61  ##     import sys 
 62   
 63  ##     limit = sys.getrecursionlimit() 
 64   
 65  ##     while limit < MAX_RECURSION_LIMIT: 
 66   
 67  ##         try: 
 68  ##             return _loads(object) 
 69   
 70  ##         except RuntimeError: 
 71  ##             limit += 1000 
 72  ##             sys.setrecursionlimit(limit) 
 73   
 74  ##     raise RuntimeError, "Maximum recursion depth exceeded." 
 75   
 76   
77 -def pack(object):
78 return pkstr(dumps(object))
79 80
81 -def unpack():
82 return loads(upkstr())
83 84
85 -def pack_and_send(tid, msg_tag, object, encoding = None):
86 if encoding is None: 87 encoding = data['default'] 88 89 return psend_str(encoding, tid, msg_tag, dumps(object))
90 91
92 -def addHosts(hosts):
93 """ 94 Add hosts to PVM. 95 96 @param hosts: list of hostnames 97 @type hosts: [str] 98 """ 99 for host in hosts: 100 try: 101 result = addhosts([host]) 102 except: 103 print host,'failed'
104 105
106 -def delHosts(hosts):
107 """ 108 Remove hosts from PVM. 109 110 @param hosts: list of hostnames 111 @type hosts: [str] 112 """ 113 return delhosts( hosts )
114