zooniverse_data 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e04d2fd630674b787a643f6ef1143ae3636c3432
4
- data.tar.gz: f0329fe298057f1a9eb412b0014b072c91d35573
3
+ metadata.gz: c177a4164665bc2d3b784b192f4cc2101139a83d
4
+ data.tar.gz: b7de110057268047631c9dcaeb9e3f355a3d63b0
5
5
  SHA512:
6
- metadata.gz: 6ade5bc4f3958859d0b9e709df9449edc1cebbbb7b781685c8affe00de0499dbc06ae260395b96d95d9fb2fe9861738d0cbbaf734e5be1b6d8a8b83113ed7c54
7
- data.tar.gz: 95bdc0b39012ab5b7926d2a536c959324ec08b813e4a41c4c4b0d2753b72afaa14c25bbe9cb1a05e2df54eb017defb2785e8728e2aa3684b7dd648efb33119fc
6
+ metadata.gz: 23680cf0621e8335a9ae7bf39fb66ee360024e27fb713520b2188f81ae4d76cea441a1dcf714cb678dd03387bb57ab5ff46eb8c8db39bb0ac6a0f7ce7c1011a0
7
+ data.tar.gz: 4427696fd4eccccedbd78403a4d9cb442d2ce676b546f4652b567c1cea62d15cca0df05d3a16328e26a309c772f98cff34ddae2e31da3b31ffb7cfca6695fa8f
@@ -15,9 +15,7 @@ module ZooniverseData
15
15
  def download(from: nil, to: nil, timeout: 60)
16
16
  _with_retries(20) do
17
17
  `rm -f '#{ to }'`
18
- Timeout::timeout(timeout) do
19
- `wget '#{ from }' -t 50 -c -q -O '#{ to }'`
20
- end
18
+ spawn_with_timeout command: "wget '#{ from }' -t 50 -c -q -O '#{ to }'", timeout: timeout
21
19
 
22
20
  raise 'File not downloaded' unless File.exists?(to)
23
21
  raise 'File is empty' unless File.new(to).size > 0
@@ -49,6 +47,20 @@ module ZooniverseData
49
47
  @bucket_path ||= manifest.project.bucket_path
50
48
  end
51
49
 
50
+ def spawn_with_timeout(command: command, timeout: timeout)
51
+ pid = Process.spawn command, close_others: true
52
+
53
+ begin
54
+ Timeout::timeout(timeout) do
55
+ Process.wait pid
56
+ end
57
+ rescue => e
58
+ Process.kill 'TERM', pid
59
+ Process.detach pid
60
+ raise e
61
+ end
62
+ end
63
+
52
64
  def _with_retries(retries)
53
65
  tries = 0
54
66
  begin
@@ -1,3 +1,3 @@
1
1
  module ZooniverseData
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zooniverse_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Parrish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler