infinite-loop

Scala while(true) type mismatch? Infinite loop in scala?

妖精的绣舞 提交于 2019-12-05 18:22:18
问题 Why following code def doSomething() = "Something" var availableRetries: Int = 10 def process(): String = { while (true) { availableRetries -= 1 try { return doSomething() } catch { case e: Exception => { if (availableRetries < 0) { throw e } } } } } produces following compiler error error: type mismatch; found : Unit required: String while (true) { ^ ? This works ok in C#. The while loops forever, so it cannot terminate, therefore it cannot result something else than string. Or how to make

How to run infinitely script in background on Linux?

[亡魂溺海] 提交于 2019-12-05 16:40:43
问题 I have a PHP script with infinite loop. I need this script running forever. So, I run php /path/to/script.php > /dev/null & And it works in background in my current user's security context. But when I close terminal window (log off), of course, CentOS Linux kills my program. I see two guesses: run from a different user in background or make a daemon. I need help in each situation. Thanks a lot! 回答1: nohup is your friend. nohup command & 回答2: I think the general solution to that is nohup:

Laravel 5 redirect loop error

∥☆過路亽.° 提交于 2019-12-05 15:42:40
问题 I trying to make a login and admin script, the problem is that I have a redirect loop I dont know why. I want the login users and can be in the / path not /home . If change return new RedirectResponse(url('/')); to return new RedirectResponse(url('/anotherpage')); it works but I want to be / Routes: Route::get('/', [ 'as' => 'home', 'uses' => 'HomeController@index' ]); // Tutorials Routes Route::get('/tutorials', 'HomeController@tutorials'); Route::get('/tutorials/{category?}',

Limiting execution time of embedded Python

空扰寡人 提交于 2019-12-05 15:38:15
问题 If I embed the Python interpreter in a C or C++ program, as in this example, is there any way to limit how long the interpreter runs for? Is there anything to stop the Python code from entering an infinite loop and thus preventing PyObject_CallObject (or equivalent) from ever returning? Similarly, if the Python code creates a new thread, is there anything to stop this thread from entering an infinite loop and running forever? 回答1: As you can see in the docs, PyObject_CallObject has no

Entity Framework Navigation Properties looping issue though WCF

半世苍凉 提交于 2019-12-05 08:50:35
I have a model like public class User { [Key] public long UserId { get; set; } [Required] public String Nickname { get; set; } public virtual ICollection<Group> Memberships { get; set; } } public class Group { [Key] public long GroupId { get; set; } [Required] public String Name { get; set; } public virtual ICollection<User> Members { get; set; } } public class DataContext : DbContext { public DbSet<User> Users { get; set; } public DbSet<Group> Groups { get; set; } public DataContext() { Configuration.LazyLoadingEnabled = true; } protected override void OnModelCreating(DbModelBuilder

Infinite loop problem with while loop and threading [duplicate]

寵の児 提交于 2019-12-05 08:27:36
This question already has an answer here : Loop doesn't see value changed by other thread without a print statement (1 answer) Closed 5 years ago . Using a basic example to illustrate my problem I have 2 near-identical bits of code. This code causes the while loop to run infinitely. private boolean loadAsset() { new Thread(new Runnable() { @Override public void run() { // Do something loaded = true; } }).start(); while (!loaded) { // System.out.println("Not Loaded"); } System.out.println("Loaded"); return false; } This code however (i.e. doing something in the while loop) causes the loaded

My cin is being ignored inside a while loop

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 08:12:52
I am trying to code a simple question and number checker into my first C++ program. Problem is, when I type a string like one two, or three, the program becomes and infinite loop and it ignores the cin function to re-assign lives to a number. cout << "How many lives would you like 1 (hard), 2 (medium), or 3 (easy)?" << endl; cin >> lives; while(lives != 1 && lives != 2 && lives != 3 && !isdigit(lives)) { cout << "You need to input a number, not words." << endl; cout << "How many lives would you like 1 (hard), 2 (medium), or 3 (easy)?" << endl; cin >> lives; } Here is my current code with your

Passing variable through URL with angular js

。_饼干妹妹 提交于 2019-12-05 03:31:25
I am using angular to make an e-commerce, and I'm setting an infinite scroll to the products list page. Everything worked fine, but I want to use the URL to set the page, so the user can access an specific page through URL. how do I set a variable like "pageNumber" in the URL with angular? like "www.page.com/page/2/"(I want to get the number 2 and pass it to the store controller) Here's the code I have now (function() { var app = angular.module('concurseirosUnidos', ['store-directives', 'ngRoute']); app.config(function($routeProvider, $locationProvider){ $locationProvider.html5Mode(true);

Why my FB app loops forever in IE?

回眸只為那壹抹淺笑 提交于 2019-12-05 02:17:55
问题 I have a Facebook app which loops forever when run in IE. In other browsers it works fine. I need your help to debug this, but before that I need to mention how I have implemented it. FB recommends that when user tries to access the app we should redirect the user to the app authorization page. From there FB will redirect (using 302 code) to an url which we like. In this case I ask FB to redirect to my app's url with a flag appLogin=1 in query string. But along with that FB attaches a really

Redirect loop on wp-admin or wp-login.php

杀马特。学长 韩版系。学妹 提交于 2019-12-05 00:38:28
问题 I put together a quick WordPress site locally using MAMP, then checked it into an SVN repo. I then checked it out on to my development server. I didn't change anything except to run the search and replace tool script from Interconnectit to updated the URL of the site in the database on the server. Initially, I got a 500 server error. Checking the logs, I discovered that this "SoftException" was because index.php was writeable by group - the permissions were 664. No problem - a quick change of