locking

Timeout expired when querying SQL Server via NHibernate

半世苍凉 提交于 2019-12-04 21:09:06
I have an ASP.Net MVC application that uses SQL Server 2005 via NHibernate. I am getting getting the following error message sporadically: "System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser

Run a script when either locking or unlocking Windows XP

你离开我真会死。 提交于 2019-12-04 21:07:20
问题 I have a Windows XP machine and a Linux machine running Ubuntu. I share the keyboard/mouse from the Windows machine via Synergy. What I would like to do is lock/unlock the Linux machine whenever I lock/unlock the Windows machine. So I'd like to be able to run a script of some description when Windows either locks or unlocks the screen. 回答1: The standard way in Windows is to write a package (a dll ) that subscribes to Winlogon notification events. I don't know of any tool that provides an easy

Can memcached be used for locking?

谁说我不能喝 提交于 2019-12-04 20:34:18
memcached can be used for a caching static data which reduces database lookup and typically does memcached.get(id) and memcached.set(id) . However is it fine to use this for locking mechanisms? Does memcache.set and memcached.get always give the data if it is present or will it just return None if the request is taking too much time? I want to avoid concurrent access to a particular resource identified by a id and I use this logic: def access(id): if memcache.get(id): return access else: memcache.set(id) return true If any user tries to access that resource, if memcache.get(id) = username

How to get process PID for manual lock mechanism in Python?

前提是你 提交于 2019-12-04 20:33:39
I would like to make a simple locking mechanism in Python without having to rely on the existing libraries for locking (namely fcntl and probably others) I already have a small stub, but after searching for a bit I couldn't find a good on answer on how to manually create the lock file and put the process PID inside. Here is my stub: dir_name = "/var/lock/mycompany" file_name = "myapp.pid" lock = os.path.join(dir_name, file_name) if os.path.exists(lock): print >> sys.stderr, "already running under %s, exiting..." % lock # display process PID contained in the file, not relevant to my question

Unexpected Locking for Table with Primary Key & Unique Key

廉价感情. 提交于 2019-12-04 20:27:21
问题 I've run into an innodb locking issue for transactions on a table with both a primary key and a separate unique index. It seems if a TX deletes a record using a unique key, and then re-inserts that same record, this will result in a next-key lock instead of the expected record lock (since the key is unique). See below for a test case as well as breakdown of what records I expect to have what locks: DROP TABLE IF EXISTS foo; CREATE TABLE `foo` ( `i` INT(11) NOT NULL, `j` INT(11) DEFAULT NULL,

How to use Multithreading, locks, Socket Programming

非 Y 不嫁゛ 提交于 2019-12-04 19:28:25
For last 48 hours, I have been trying to understand Multithreading and Socket Programming . I tried to implement socket programming and had success when not using multithreading. I am new to both of the topics and have raised 2-3 question on stack itself needing help on the same. After googling a lot I found an article that explains Socket Programming and Multithreading , but I still have a lot of doubts in this article and got stuck at Figure 5 in the article. private void AcceptConnections() { while (true) { // Accept a connection Socket socket = _serverSocket.Accept(); ConnectionInfo

Sybase: trying to lock a record on select so another caller does not get the same one

喜你入骨 提交于 2019-12-04 19:15:50
I have a simple table in Sybase, let's say it looks as follows: CREATE TABLE T ( name VARCHAR(10), entry_date datetime, in_use CHAR(1) ) I want to get the next entry based on order of "entry_date" and immediately update "in_use" to "Y" to indicate that the record is not available to the next query that comes in. The kicker is that if two execution paths try to run the query at the same time I want the second one to block so it does not grab the same record. The problem is I've found that you cannot do "SELECT FOR UPDATE" in Sybase if you have an ORDER BY clause, so the following stored proc

When should I use semaphores?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 19:13:58
问题 When would one use semaphores ? Only example I can think of is limiting the number of threads accessing the same data/code simultaneously... Any other scenarios in which semaphores would be the best solution ? 回答1: Semaphores might be appropriate for signaling between processes. For multithreaded programming, semaphores should be avoided. If you need exclusive access to a resource, use mutex. If you need to wait for a signal, use condition variable. Even the most often mentioned case of a

Android Display own lock instead of default when screen on/off

无人久伴 提交于 2019-12-04 19:08:26
i want to open my created lock instead of default one,when phone is boot at that time my lock is called. But i want to know when my screen on after locked at that time how i called my lock (my lock activity)Means i want to display my lock instead of default at time of screen on or phone restart or switch on all time. like in our phone lock called all time same as i want to call my lock all time( done with boot ).so please any one help me how i call my lock when screen on/off.please help quickly thanks.... i do for boot time call my lock following exactly i that i want for screen-on/off {

Directory lock error with Lucene.Net usage in an ASP.NET MVC site

有些话、适合烂在心里 提交于 2019-12-04 18:35:54
问题 I'm building an ASP.NET MVC site where I want to use Lucene.Net for search. I've already built a SearchController and all of its methods, but I'm getting an error at runtime that occurs when the SearchController is first initialized. In SearchController, here's how I'm creating an IndexWriter: public static string IndexLocation = HostingEnvironment.MapPath("~/lucene"); public static Lucene.Net.Analysis.Standard.StandardAnalyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer();