with_process_lock 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83bf12114657b9d0326361df84cc0e452fea6f16
4
- data.tar.gz: 71489d9b4a41f8d451662c879b85fe17703d4081
3
+ metadata.gz: 0af2c6f49c7b058970c7fc98be0949625b6f005d
4
+ data.tar.gz: '005991b9d6d6355c7c98e9ed0aa9241c3e2b147d'
5
5
  SHA512:
6
- metadata.gz: 8db55fc3de054a7a81348bc705b6b89dcd256dafd6a6e37d3ebcfb83b616f8bbcf4761320291b2a701adbedfd10e424e7453f7a8b7864bfcdb75d9a9f48afe50
7
- data.tar.gz: a40bc3380ad50a2bd7bef7dfbe84257a358dffb7fc7f24df6627d83c63dd44d7c0f1c7a1a5a86ce020db61bb8c374c495338a089137bcd06adf98185ad77a60b
6
+ metadata.gz: 7c34ceac06e7d7e8ffdb256a968a9e8464161fc742065cc3679ab5acdc19c810099c30f084f59940a746d913285509db1bc679426101d0296bc4e3ad6bd05eda
7
+ data.tar.gz: 6a700c32cff253497e62aa6e668b95b692ce359dbff3d5e5786154dd00687585ab2e89ea290a2df4164cf7bb23388c0adf73cda47693c3087117502ef25fa9c2
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -1,3 +1,3 @@
1
1
  module ProcessLock
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,11 +1,16 @@
1
1
  module ProcessLock
2
2
  class WithProcessLock
3
+
3
4
  def self.execute(key, &blk)
4
5
  if can_execute?(key)
5
6
  redis.set(key, true)
6
- yield blk
7
- redis.del(key)
8
- redis.quit
7
+ begin
8
+ yield blk
9
+ ensure
10
+ # Delete the key and quit redis even if the block raises an exception
11
+ redis.del(key)
12
+ redis.quit
13
+ end
9
14
  else
10
15
  redis.quit
11
16
  raise StandardError, "Can not run process because #{key} taken."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: with_process_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Friedman