question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting lots of "Unable to aquire Singleton lock" during localhost development

See original GitHub issue

Heya 😃

So I’ve just started playing around / trying to use the TimerTrigger with a new webjob. I’m doing localhost development to make sure the code works, before I deploy it up to Azure.

To do this, I click F5 to Debug my webjob console app. Ok, great! works/etc… I then stop this (or the code throws an exception and crashes).

I then change one tiny thing and then hit F5 again … and then get this:

image

Sometimes, I wait 10 or even 20 seconds after the webjob stopped/stops and then hit F5 and still get that error.

Shouldn’t the host 100% tear down after it’s stopped? I should be able to hit F5, then close app, then hit F5 straight away, right?

Update / More info.

Here’s my program.cs as a reference:

    class Program
    {
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();
            config.Tracing.ConsoleLevel = TraceLevel.Verbose;

            config.UseTimers();

            var host = new JobHost(config);
            host.RunAndBlock();

            //var host = new JobHost();
            //// The following code ensures that the WebJob will be running continuously
            //host.RunAndBlock();
        }
    }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mathewccommented, Dec 17, 2015

Ok, I’ve added JobHostConfiguration.IsDevelopment and JobHostConfiguration.UseDevelopmentSettings(). You can see an example in the extensions sample here. This new method sets up all the optimal local dev settings as mentioned above.

See the xml doc on these new methods for details. Basically if your environment has a setting AzureWebJobsEnv, IsDevelopment will be true. Note that these changes are in prerelease packages available on myget.

1reaction
PureKromecommented, Dec 15, 2015

The intent is for you NOT to have to discover anything about these low level details. It should just work for people

I’m all for that 😃 Was just thinking about options, but yes! all for that 😃

One option would be for the SDK to use a lower default lease period when running locally This I really like. But … how do you define ‘locally’ ? via the connection string?

e.g.: <Setting name="AzureConnectionString" value="UseDevelopmentStorage=true" />

However, this would work well for the “getting started” case where a person is only running locally at the time. That’s the use case I’m mainly targetting in this issue - so yep 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve unable to acquire singleton lock issue in ...
Make sure no instance of the web job is running in Azure. That means, stop the web job in Azure. Even the local...
Read more >
How to resolve unable to acquire singleton lock issue in Azure ...
After looking at everything I figured out what it was: Make sure no instance of the web job is running in Azure. That...
Read more >
Reducing initial request latency by pre-building services in ...
In this post I show a startup task that pre-builds all the services registered in the DI container to reduce the duration of...
Read more >
host.json reference for Azure Functions 2.x and later
Reference documentation for the Azure Functions host.json file with the v2 runtime.
Read more >
Contexts and Dependency Injection
If it's not possible to acquire the lock in the given time a LockException is thrown. 4.14. Repeatable interceptor bindings. Quarkus has limited...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found