即使app没有运行,我也想在后台运行我的计时器.因为我希望在一段时间间隔后得到用户的gps坐标.这样做的方法是什么?
我有一个Win RT应用程序,它有一个后台任务,负责调用API来检索自己更新所需的数据.但是,我遇到了一个问题; 在后台任务之外运行时,调用API的请求可以正常工作.在后台任务中,它失败了,并且还隐藏了任何可以帮助指出问题的异常.
我通过调试器跟踪此问题以跟踪问题点,并验证执行在GetAsync上停止.(我传递的URL有效,URL在不到一秒的时间内响应)
var client = new HttpClient("http://www.some-base-url.com/");
try
{
    response = await client.GetAsync("valid-url");
    // Never gets here
    Debug.WriteLine("Done!");
}
catch (Exception exception)
{
    // No exception is thrown, never gets here
    Debug.WriteLine("Das Exception! " + exception);
}
我读过的所有文档都说允许后台任务拥有所需的网络流量(当然会受到限制).所以,我不明白为什么会失败,或者知道任何其他方法来诊断问题.我错过了什么?
UPDATE/ANSWER
感谢史蒂文,他指出了解决问题的方法.在确保定义的答案就在那里,利益在这里是后台任务前和修复程序后:
之前
public void Run(IBackgroundTaskInstance taskInstance)
{
    BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
    Update();
    deferral.Complete();
}
public async void Update()
{
    ...
}
后
public async void Run(IBackgroundTaskInstance taskInstance) // added 'async'
{
    BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
    await Update(); // added …我在PHP中制作了一个长脚本:
ignore_user_abort(true);
set_time_limit(0);
即使我关闭页面,它也能在后台完美运行.我的问题是,在此脚本在后台运行之前,我无法打开其他PHP文件.我怎么解决这个问题?
我有一个使用蓝牙4.0 LE的应用程序.该应用程序允许设备充当中央和外围设备.
我希望应用程序在后台运行.我已经在info.plist中包含了带有"bluetooth-central"和"bluetooth-peripheral"的UIBackgroundModes.
我正在两个启用了蓝牙4.0 LE的设备上运行该应用程序.
当两个设备都在前台运行时,一切都运行良好,信息双向传递.
当一台设备在前台运行而另一台设备在后台运行时,在后台运行的设备可以扫描和通告,但无法发现在后台运行的其他设备.在前台运行的设备能够发现并连接到后台运行的设备.
通过Apple的核心蓝牙编程指南阅读后,我知道可以连接到另一台设备并以两种方式共享信息.
我可以根据要求发布更多信息.谢谢.
bluetooth background-process ios core-bluetooth bluetooth-lowenergy
有没有办法判断我的python脚本是否作为后台进程运行?我试图区分这两者:
sudo ./myscript.py
sudo ./myscript.py &
使用sys.argv不起作用 - &符号显然不算作参数.以下是对以下内容的影响:
sudo python myscript.py
sudo python myscript.py &
我已经浏览了一下,但一切似乎都是关于从Python脚本中启动后台进程,而不是Python脚本本身是否是后台进程.谢谢!
编辑:目的是输出消息(或不输出),即 "Press Ctrl+C to stop this script"如果正常启动,但如果作为后台进程启动则不显示消息.
编辑2我忽略了提到这个python脚本将由脚本启动, 
 /etc/init.d而不是从终端提示符启动.因此,标记为正确的答案确实回答了我所说的问题以及给出的信息,但我认为我应该指出它在init.d情景中不起作用,以避免将来出现任何可能的混淆.
有没有办法唤醒iOS父应用程序并让父应用程序在今天的小部件视图中主动在后台运行(但不能打开应用程序)?
我的目标很简单:启动rsync并且不要等待.
Debian上的Python 2.7.9
示例代码:
rsync_cmd = "/usr/bin/rsync -a -e 'ssh -i /home/myuser/.ssh/id_rsa' {0}@{1}:'{2}' {3}".format(remote_user, remote_server, file1, file1)
rsync_cmd2 = "/usr/bin/rsync -a -e 'ssh -i /home/myuser/.ssh/id_rsa' {0}@{1}:'{2}' {3} &".format(remote_user, remote_server, file1, file1)
rsync_path = "/usr/bin/rsync"
rsync_args = shlex.split("-a -e 'ssh -i /home/mysuser/.ssh/id_rsa' {0}@{1}:'{2}' {3}".format(remote_user, remote_server, file1, file1))
#subprocess.call(rsync_cmd, shell=True)     # This isn't supposed to work but I tried it
#subprocess.Popen(rsync_cmd, shell=True)    # This is supposed to be the solution but not for me
#subprocess.Popen(rsync_cmd2, shell=True)   # Adding my own shell "&" …我需要允许用户提交非常大的工作请求.我们正在谈论100千兆字节的内存和20小时的计算时间.这花费了我们公司很多钱,因此规定任何时候只能运行2个作业,并且当2个已经运行时请求新作业将被拒绝(并且用户通知服务器正忙).
我当前的解决方案使用来自concurrent.futures的Executor,并且需要将Apache服务器设置为仅运行一个进程,从而降低响应速度(当前用户数非常低,因此现在可以正常使用).
如果可能的话我想使用Celery,但我没有在文档中看到任何方法来完成这个特定的设置.
如何在Django应用程序中在后台运行有限数量的作业,并在作业因服务器繁忙而被拒绝时通知用户?
我有一个服务,用于发送在后台运行的http请求,并在"正常模式"下正常工作.问题是当我将手机置于"省电模式"时,该服务无法正常工作.但是,像Whatsapp这样的应用仍然有效.你知道发生了什么吗?
在我的网络应用程序中,我对长时间运行的任务执行操作,并且我想在后台调用此任务。因此,根据文档 .NET Core 3.1排队后台任务,我使用这样的代码:
public interface IBackgroundTaskQueue
{
    ValueTask QueueBackgroundWorkItemAsync(Func<CancellationToken, ValueTask> workItem);
    ValueTask<Func<CancellationToken, ValueTask>> DequeueAsync(CancellationToken cancellationToken);
}
public class BackgroundTaskQueue : IBackgroundTaskQueue
{
    private readonly Channel<Func<CancellationToken, ValueTask>> _queue;
    public BackgroundTaskQueue(int capacity)
    {
        var options = new BoundedChannelOptions(capacity){FullMode = BoundedChannelFullMode.Wait};
        _queue = Channel.CreateBounded<Func<CancellationToken, ValueTask>>(options);
    }
    public async ValueTask QueueBackgroundWorkItemAsync(Func<CancellationToken, ValueTask> workItem)
    {
        if (workItem == null)throw new ArgumentNullException(nameof(workItem));
        await _queue.Writer.WriteAsync(workItem);
    }
    public async ValueTask<Func<CancellationToken, ValueTask>> DequeueAsync(CancellationToken cancellationToken)
    {
        var workItem = await _queue.Reader.ReadAsync(cancellationToken);
        return workItem;
    }
}
和托管服务
public …python ×3
.net ×1
.net-core ×1
android ×1
asynchronous ×1
bluetooth ×1
c# ×1
celery ×1
django ×1
ios ×1
iphone ×1
java ×1
objective-c ×1
php ×1
popen ×1
self-hosting ×1
session ×1
subprocess ×1
windows-8 ×1