infinite-loop

Infinite loop when trying to make Angularjs display a promise

断了今生、忘了曾经 提交于 2020-01-17 03:51:05
问题 I'm facing an infinite loop when trying to make AngularJS display a promise, as explained in this article: http://markdalgleish.com/2013/06/using-promises-in-angularjs-views/. I first call $parseProvider.unwrapPromises(true); : .config(["$parseProvider", function($parseProvider) { $parseProvider.unwrapPromises(true); }]) Here is the factory I use to access a message: app.factory("MessageHelper", [ function() { // omitted for brevity: // calling the server for getting the messages return { get

Strange observation on nodejs infinite loop function execution

╄→尐↘猪︶ㄣ 提交于 2020-01-16 18:03:52
问题 I recently came across the article Tail call optimization in ECMAScript 6. I was interested in testing the TCO behavior (Even though I later found that the TCO was not supported by nodejs 8+ as mentioned by the article) and found behavior that I could not understand. Plain loop function 'use strict'; process.on('SIGTERM', () => { console.log('SIGTERM received'); process.exit(0); }) process.on('SIGINT', () => { console.log('SIGINT received'); process.exit(0); }) process.on('uncaughtException',

How to test that a method should take more than X seconds to finish(with JUnit)?

点点圈 提交于 2020-01-15 08:11:13
问题 Basically I need the opposite behaviour of the @Test(timeout=X) annotation. The problem I want to solve is to detect in some way that the method never ends (as a right behaviour). I am assuming that if the method didn't stop after X seconds, I am sure "it will never end". Thanks! 回答1: You could try this: @Test public void methodDoesNotReturnFor5Seconds() throws Exception { Thread t = new Thread(new Runnable() { public void run() { methodUnderTest(); } }); t.start(); t.join(5000); assertTrue(t

Find whether graph has a cycle

為{幸葍}努か 提交于 2020-01-15 05:48:25
问题 I want to find out whether it is possible to find cycles in Hierarchical or Chain data with SQL. E.g. I have following schema: http://sqlfiddle.com/#!3/27269 create table node ( id INTEGER ); create table edges ( id INTEGER, node_a INTEGER, node_b INTEGER ); create table graph ( id INTEGER, edge_id INTEGER); INSERT INTO node VALUES (1) , (2), (3), (4); INSERT INTO edges VALUES (1, 1, 2), (2, 2, 3) , (3, 3, 4) , (4, 4, 1); -- first graph [id = 1] with cycle (1 -> 2 -> 3 -> 4 -> 1) INSERT INTO

urlfetch redirected into an infinite loop in python

和自甴很熟 提交于 2020-01-14 18:46:46
问题 I am trying to load a url which redirects to itself. I'm assuming its loading a cookie and its looking for it but it never sees it so there is this infinite loop of requests. I have tried urllib2, urlfetch, and httplib2. None work. I tried this though: url = "http://www.cafebonappetit.com/menu/your-cafe/collins-cmc/cafes/details/50/collins-bistro" thing = urllib2.HTTPRedirectHandler() thing2 = urllib2.HTTPCookieProcessor() opener = urllib2.build_opener(thing, thing2) url = 'http://www.nytimes

Java : Recursion -While Loop Vs If Loop

爱⌒轻易说出口 提交于 2020-01-14 05:17:13
问题 Code Design 1 : works perfectly public static void main (String[] args) { recursion(2); } public static void recursion(int num) { if (num > 0) { recursion( num - 1 ); System.out.println(num); } } Code Design 2 : Infinite Loop. ? public static void main (String[] args) { recursion(2); } public static void recursion(int num) { if (num == 0) return; while (num > 0) { recursion( num - 1 ); System.out.println(num); } } Can someone plz help me in understanding why 2nd design is getting into

JavaScript deadlock

ⅰ亾dé卋堺 提交于 2020-01-14 04:14:10
问题 Here I saw JavaScript deadlocks and this code: var loop = true, block = setTimeout(function(){loop = false}, 1); while(loop); It's definitely infinite loop and causes to browser freezing. It's said that deadlock is created when one operation wait another one to be executed and vice-versa . My question is, except that, what kind of situations deadlock occurs and the ways to avoid them? 回答1: That's not a deadlock, just an infinite loop, you can't have a deadlock in JavaScript as you can't have

angularjs infinite $digest Loop when no scope changes

放肆的年华 提交于 2020-01-12 07:08:06
问题 I'm getting the below error in my angular code. I'm struggling to understand why the function getDrawWithResults would cause a digest cycle as there don't seem to be any side effects? It just returns items from a list that have a property set to true. The error only occurs when the first use of getDrawWithResults is on the page, if I remove, the error stops. Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[

angularjs infinite $digest Loop when no scope changes

别来无恙 提交于 2020-01-12 07:08:02
问题 I'm getting the below error in my angular code. I'm struggling to understand why the function getDrawWithResults would cause a digest cycle as there don't seem to be any side effects? It just returns items from a list that have a property set to true. The error only occurs when the first use of getDrawWithResults is on the page, if I remove, the error stops. Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[

What could cause an Android activity to relaunch itself infinitely when returning from camera?

馋奶兔 提交于 2020-01-12 04:57:05
问题 I have a weird bug in my application that causes an activity to relaunch itself in an infinite loop when I'm returning from a camera application, after taking a picture. The UI flow is like this: Main Activity -> Accept Photo activity -> in onCreate() open camera with startActivityForResult() Camera screen -> take picture (or cancel) -> return to Accept Photo The Accept Photo screen is created completely and immediately stopped and recreated in an infinite loop The weird part is that it only