/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/load_test.py

  • Committer: John Arbash Meinel
  • Date: 2011-02-10 00:23:33 UTC
  • mto: This revision was merged to the branch mainline in revision 426.
  • Revision ID: john@arbash-meinel.com-20110210002333-sv5ibj14iwjrun86
Full integration test.

We set the blocking timeout low, and the Worker request to one tenth
of that. Otherwise the workers are blocked waiting for more work
while the ActionScript is trying to join against the threads.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        base, path = urlutils.split(url)
119
119
        t = transport.get_transport(base)
120
120
        try:
 
121
            # TODO: We should probably look into using some part of
 
122
            #       blocking_timeout to decide when to stop trying to read
 
123
            #       content
121
124
            content = t.get_bytes(path)
122
125
        except (errors.TransportError, errors.NoSuchFile):
123
126
            return False
171
174
        if thread_id in self._threads:
172
175
            return self._threads[thread_id][0]
173
176
        handler = self._worker_class(thread_id,
174
 
                                     blocking_time=self.blocking_timeout)
 
177
                                     blocking_time=self.blocking_timeout/10.0)
175
178
 
176
179
        t = threading.Thread(target=handler.run, args=(self.stop_event,),
177
180
                             name='Thread-%s' % (thread_id,))
192
195
        self.stop_event.set()
193
196
        for h, t in self._threads.itervalues():
194
197
            # And join the controlling thread
195
 
            t.join(self.blocking_timeout)
 
198
            for i in range(10):
 
199
                t.join(self.blocking_timeout / 10.0)
 
200
                if not t.isAlive():
 
201
                    break
196
202
 
197
203
    def _full_url(self, relpath):
198
204
        return self.base_url + relpath
202
208
        for request in self._requests:
203
209
            full_url = self._full_url(request.relpath)
204
210
            worker = self._get_worker(request.thread)
205
 
            worker.queue.put(full_url)
 
211
            worker.queue.put(full_url, True, self.blocking_timeout)
206
212
        self.finish_queues()
207
213
        self.stop_and_join()