semaphore

Semaphore - What is the use of initial count?

拟墨画扇 提交于 2021-02-17 07:33:12
问题 http://msdn.microsoft.com/en-us/library/system.threading.semaphoreslim.aspx To create a semaphore, I need to provide an initial count and maximum count. MSDN states that an initial count is - The initial number of requests for the semaphore that can be granted concurrently. While it states that maximum count is The maximum number of requests for the semaphore that can be granted concurrently. I can understand that the maximum count is the maximum number of threads that can access a resource

com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open with multiprocessing

六月ゝ 毕业季﹏ 提交于 2021-02-10 14:36:34
问题 I am building an application that works on windows and in python. It builds correctly and this issue looks like it should have been fixed in 7.0.3 of chaquopy; however it does not work for me. I have included the logcat from the attempt to run on the android vm. Any help would be really appreciated. I can include more error messages or more output from the logcat if needed. // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext

com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open with multiprocessing

帅比萌擦擦* 提交于 2021-02-10 14:35:23
问题 I am building an application that works on windows and in python. It builds correctly and this issue looks like it should have been fixed in 7.0.3 of chaquopy; however it does not work for me. I have included the logcat from the attempt to run on the android vm. Any help would be really appreciated. I can include more error messages or more output from the logcat if needed. // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext

Distributed counting semaphore in Java

江枫思渺然 提交于 2021-02-10 06:00:17
问题 I am looking for a distributed semaphore implementation (with postgres / zookeeper as store) that is similar to the concept of java.util.concurrent.Semaphore which will maintain a set of permits that will be taken using acquire() and released with release() allowing me to restrict access to some resource or synchronize some execution. The only difference is that this semaphore should allow me to do all these actions across multiple jvms. Can someone point to me if there is any such

semaphore doesn't work as expected in my case

吃可爱长大的小学妹 提交于 2021-02-08 11:13:14
问题 This is the scenario: I want to add an observer to monitor events & when an event is triggered & processed, I wait for the result in callback block, if result is fine, I do other task. If wait timeout, I just print error message. I use semaphore to achieve the above thing with the following simple code: -(void)waitForResultThenDoOtherTask { BOOL shouldPrintErr = NO; // I create a semaphore dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); // I have an observer with a callback,

semaphore doesn't work as expected in my case

落花浮王杯 提交于 2021-02-08 11:12:35
问题 This is the scenario: I want to add an observer to monitor events & when an event is triggered & processed, I wait for the result in callback block, if result is fine, I do other task. If wait timeout, I just print error message. I use semaphore to achieve the above thing with the following simple code: -(void)waitForResultThenDoOtherTask { BOOL shouldPrintErr = NO; // I create a semaphore dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); // I have an observer with a callback,

How to create Semaphores in c?

拜拜、爱过 提交于 2021-02-07 18:44:58
问题 Im trying to recreate a "Blackbox" library. In my CS class when we are supposed to use Semaphores (in our on paper final) we are given a "sem.h" file. there are 3 functions one for creating a new Semaphore with an inital number of tokens, one for taking a token out of a semaphore and one for placing a token into a semaphore. at 0 tokes any thread using the blocking funktion has to wait for a token. for better understanding ive been trying to recreate this sem.h and sem.c based on some exams

sem_wait not unblocking with EINTR

寵の児 提交于 2021-02-07 10:51:42
问题 I'm new with semaphores and want to add multithreading to my program, but I cannot get around the following problem: sem_wait() should be able to receive a EINTR and unblock, as long as I didn't set the SA_RESTART flag. I am sending a SIGUSR1 to the worker thread that is blocking in sem_wait(), it does receive the signal and get interrupted, but it will then continue to block and so it will never give me a -1 return code together with errno = EINTR. However, if I do a sem_post from the main

Queuing asynchronous task in C#

霸气de小男生 提交于 2021-02-05 09:59:49
问题 I have few methods that report some data to Data base. We want to invoke all calls to Data service asynchronously. These calls to data service are all over and so we want to make sure that these DS calls are executed one after another in order at any given time. Initially, i was using async await on each of these methods and each of the calls were executed asynchronously but we found out if they are out of sequence then there are room for errors. So, i thought we should queue all these

RuntimeWarning: Enable tracemalloc to get the object allocation traceback with asyncio.sleep

主宰稳场 提交于 2021-02-04 12:08:17
问题 Trying to use a semaphore to control asynchronous requests to control the requests to my target host but I am getting the following error which I have assume means that my asycio.sleep() is not actually sleeping. How can I fix this? I want to add a delay to my requests for each URL targeted. Error: RuntimeWarning: coroutine 'sleep' was never awaited Coroutine created at (most recent call last) File "sephora_scraper.py", line 71, in <module> loop.run_until_complete(main()) File "/Library