lfoppiano commited on
Commit
f52c6ed
·
verified ·
1 Parent(s): 47e5c00

Update service.py

Browse files
Files changed (1) hide show
  1. service.py +22 -14
service.py CHANGED
@@ -1,4 +1,5 @@
1
  import http.server
 
2
  import socketserver
3
  import subprocess
4
  import threading
@@ -19,20 +20,22 @@ def run_command(command):
19
  text=True
20
  )
21
  while True:
22
- output = process.stdout.readline()
23
- if output == '' and process.poll() is not None:
24
- command_output.put("Leaving")
 
 
 
 
 
 
 
 
25
  break
26
- if output:
27
- command_output.put(output)
28
-
29
- stderr_output = process.stderr.read()
30
- if stderr_output:
31
- command_output.put(stderr_output)
32
  process.stdout.close()
33
  process.stderr.close()
34
  process.wait()
35
-
36
 
37
  def command_worker():
38
  while True:
@@ -45,10 +48,15 @@ def command_worker():
45
 
46
  def start_commands():
47
  commands = [
48
- ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/PMC_sample_1943', '-Prun=1', '-PfileRatio=1'],
49
- ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/PLOS_1000', '-Prun=1', '-PfileRatio=1'],
50
- ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/biorxiv-10k-test-2000', '-Prun=1', '-PfileRatio=1'],
51
- ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/eLife_984', '-Prun=1', '-PfileRatio=1']
 
 
 
 
 
52
  ]
53
  for command in commands:
54
  command_queue.put(command)
 
1
  import http.server
2
+ import select
3
  import socketserver
4
  import subprocess
5
  import threading
 
20
  text=True
21
  )
22
  while True:
23
+ reads = [process.stdout.fileno(), process.stderr.fileno()]
24
+ ret = select.select(reads, [], [])
25
+ for fd in ret[0]:
26
+ if fd == process.stdout.fileno():
27
+ output = process.stdout.readline()
28
+ if output:
29
+ command_output.put(output)
30
+ error = process.stderr.readline()
31
+ if error:
32
+ command_output.put(error)
33
+ if process.poll() is not None:
34
  break
 
 
 
 
 
 
35
  process.stdout.close()
36
  process.stderr.close()
37
  process.wait()
38
+ command_output.put("Leaving")
39
 
40
  def command_worker():
41
  while True:
 
48
 
49
  def start_commands():
50
  commands = [
51
+ ['/Users/lfoppiano/development/projects/grobid/./gradlew', '-p', '/Users/lfoppiano/development/projects/grobid',
52
+ 'jatsEval', '-Pp2t=/Volumes/ExtremePro/sciencialab/science-miner/grobid/grobid-evaluation/PMC_sample_1943',
53
+ '-Prun=1', '-PfileRatio=1'],
54
+ ['/Users/lfoppiano/development/projects/grobid/./gradlew', '-p', '/Users/lfoppiano/development/projects/grobid',
55
+ 'jatsEval', '-Pp2t=/Volumes/ExtremePro/sciencialab/science-miner/grobid/grobid-evaluation/PLOS_1000',
56
+ '-Prun=1', '-PfileRatio=1'],
57
+ # ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/PLOS_1000', '-Prun=1', '-PfileRatio=1'],
58
+ # ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/biorxiv-10k-test-2000', '-Prun=1', '-PfileRatio=1'],
59
+ # ['./gradlew', 'jatsEval', '-Pp2t=/opt/grobid/evaluation/eLife_984', '-Prun=1', '-PfileRatio=1']
60
  ]
61
  for command in commands:
62
  command_queue.put(command)