Time2Internaldate
"""
-import re, socket, string, time, whrandom
+import re, socket, string, time, random
# Globals
# Create unique tag for this session,
# and compile tagged response matcher.
- self.tagpre = Int2AP(whrandom.random()*32000)
+ self.tagpre = Int2AP(random.random()*32000)
self.tagre = re.compile(r'(?P<tag>'
+ self.tagpre
+ r'\d+) (?P<type>[A-Z]+) (?P<data>.*)')
def choose_boundary():
global _prefix
import time
- import whrandom
+ import random
if _prefix == None:
import socket
import os
pid = '1'
_prefix = hostid + '.' + uid + '.' + pid
timestamp = '%.3f' % time.time()
- seed = `whrandom.randint(0, 32767)`
+ seed = `random.randint(0, 32767)`
return _prefix + '.' + timestamp + '.' + seed
import sys
import time
-import whrandom
+import random
import marshal
import tempfile
import operator
except IOError:
result = []
for i in range(n):
- result.append(whrandom.random())
+ result.append(random.random())
try:
try:
fp = open(fn, "wb")
##assert len(result) == n
# Shuffle it a bit...
for i in range(10):
- i = whrandom.randint(0, n-1)
+ i = random.randint(0, n-1)
temp = result[:i]
del result[:i]
temp.reverse()
y = (y^h^d) & 255
h = h>>8
z = (z^h^d) & 255
- whrandom.seed(x, y, z)
+ random.seed(x, y, z)
r = range(k1, k2+1) # include the end point
tabulate(r)
# Create a bunch of threads, let each do some work, wait until all are done
from test_support import verbose
-import whrandom
+import random
import thread
import time
mutex = thread.allocate_lock()
-whmutex = thread.allocate_lock() # for calls to whrandom
+rmutex = thread.allocate_lock() # for calls to random
running = 0
done = thread.allocate_lock()
done.acquire()
def task(ident):
global running
- whmutex.acquire()
- delay = whrandom.random() * numtasks
- whmutex.release()
+ rmutex.acquire()
+ delay = random.random() * numtasks
+ rmutex.release()
if verbose:
print 'task', ident, 'will run for', round(delay, 1), 'sec'
time.sleep(delay)
# of the current one
delay = 0.001
else:
- whmutex.acquire()
- delay = whrandom.random() * numtasks
- whmutex.release()
+ rmutex.acquire()
+ delay = random.random() * numtasks
+ rmutex.release()
if verbose:
print 'task', ident, 'will run for', round(delay, 1), 'sec'
time.sleep(delay)
def _test():
- import whrandom
+ import random
class BoundedQueue(_Verbose):
self.quota = quota
def run(self):
- from whrandom import random
+ from random import random
counter = 0
while counter < self.quota:
counter = counter + 1