blackstack_commons 1.1.16 → 1.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/functions.rb +12 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1a7386829f86723990a77eb63de963ed945a647
4
- data.tar.gz: f7a944473b31efb6b86cfc57ce74c1bb59d45f17
3
+ metadata.gz: 6e0549d0acf4be3d4d04d8b7490865a6086232dc
4
+ data.tar.gz: 6c8dcb58673b9118eacee8e8e4a28144edeac2e3
5
5
  SHA512:
6
- metadata.gz: 63bff98f98bfa0b28d0939aafe376d77830e191041e1a85b5e69342fa3841e471f711b34335a28f1fda9708a313f865363e7808222033138af3b2e9149e8dc7b
7
- data.tar.gz: 6a14b5ec1846858bfa9c3d0fcbd3872d5a19c267d0e6e8d3e6a0ff850950fde249070a0d8e1e1c9ff97c75ba6cfb8ed7ff0d0f14804e5faa781a0e8b5c738aba
6
+ metadata.gz: daff65cd9fc59b0d0a79c1c756dd47726a0720412d8d592ff7e6d6f72b15e0d38eb0b59ed4e32724a9e6cf0091cebd2ee842ba0666685c8873a99162cdd45a3c
7
+ data.tar.gz: 29cf4d59c7768fc2c7970a1dcbd77ce059909a4b516c956e2e8a84db34448e85e0ab9d04f3bc3b3aafec5556ee4684734f3683dc4d41bc0c46e64e4cacc577ad
data/lib/functions.rb CHANGED
@@ -449,7 +449,7 @@ module BlackStack
449
449
 
450
450
  @@lockfiles = []
451
451
 
452
- @@max_api_call_channels = 10
452
+ @@max_api_call_channels = 0 # 0 means infinite
453
453
 
454
454
  def self.max_api_call_channels()
455
455
  @@max_api_call_channels
@@ -508,11 +508,14 @@ module BlackStack
508
508
  # TODO: setup max_simultaneus_calls in the configurtion file.
509
509
  def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, use_lockfile=true)
510
510
  # build the lockfile name
511
- # raise "Max Channels cannot be higher than #{BlackStack::Netting.lockfiles.size.to_s}" if BlackStack::Netting.max_api_call_channels > BlackStack::Netting.lockfiles.size
512
- # x = rand(BlackStack::Netting.max_api_call_channels)
513
- # # lock the file
514
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
515
-
511
+ x = 0
512
+ if BlackStack::Netting.max_api_call_channels.to_i > 0
513
+ raise "Max Channels cannot be higher than #{BlackStack::Netting.lockfiles.size.to_s}" if BlackStack::Netting.max_api_call_channels > BlackStack::Netting.lockfiles.size
514
+ x = rand(BlackStack::Netting.max_api_call_channels)
515
+ # lock the file
516
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX) if use_lockfile
517
+ end
518
+
516
519
  begin
517
520
 
518
521
  # do the call
@@ -532,16 +535,16 @@ module BlackStack
532
535
  end
533
536
 
534
537
  # release the file
535
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile
538
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
536
539
  rescue => e
537
540
  # release the file
538
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile
541
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
539
542
 
540
543
  # elevo la excepcion
541
544
  raise e
542
545
  ensure
543
546
  # release the file
544
- # BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile
547
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN) if use_lockfile && BlackStack::Netting.max_api_call_channels.to_i > 0
545
548
  end
546
549
 
547
550
  # return
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.16
4
+ version: 1.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning