我有一个Windows 7环境,我需要使用Python 3.4开发Python Windows服务.我正在使用pywin32的win32service模块来设置服务,大多数钩子似乎都正常工作.
问题是当我尝试从源代码运行服务时(使用python service.py install
后跟python service.py start
).这使用PythonService.exe来托管service.py - 但我使用的是venv虚拟环境,脚本无法找到它的模块(发现错误信息python service.py debug
).
Pywin32安装在virtualenv中,在查看PythonService.exe的源代码时,它在Python34.dll中动态链接,导入我的service.py并调用它.
运行service.py时如何让PythonService.exe使用我的virtualenv?
我在一个小应用程序上工作,我希望手机在我的位置控制器的事件上播放声音文件.问题是,当应用程序处于后台模式时,AVAudioPlayer不会启动音频文件,但会调度代码,获取NSLog输出.另一件事是它在模拟器中工作但不在手机上.
不是吗?
这是我播放文件的代码:
- (void)tryPlayTaleSound:(NSString*)fileName {
NSString *backgroundMusicPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp3"];
NSURL *backgroundMusicURL = [NSURL fileURLWithPath:backgroundMusicPath];
NSError *error;
backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:&error];
// Check to see if iPod music is already playing
//UInt32 propertySize = sizeof(otherMusicIsPlaying);
//AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &propertySize, &otherMusicIsPlaying);
// Play the music if no other music is playing and we aren't playing already
//if (otherMusicIsPlaying != 1 && !backgroundMusicPlaying) {
//[backgroundMusicPlayer prepareToPlay];
[backgroundMusicPlayer play];
backgroundMusicPlaying = YES;
//}
NSLog(@"%s - ", __FUNCTION__);
}
Run Code Online (Sandbox Code Playgroud)
在日志我得到这个.
Apr …
Run Code Online (Sandbox Code Playgroud) 我遇到一个问题,在使用 Gunicorn (gevent) 运行的 django (3.2) Web 应用程序中实现的一个 API 必须从多个 API 获取不同的价格,并将这些价格存储在数据库 (Postgres 13) 中,然后再返回客户端。我想将插入放在同一个事务中,因此如果发生意外情况,则不会插入任何内容。
我现在首先调用所有 api,每个 api 都在一个绿色线程(gevent)内,然后在所有 api 返回后,我批量插入结果。
但事实证明,我真的很好奇不同的线程(绿色或非绿色)是否可以共享相同的事务。我看到 psycopg2 可以以非阻塞方式执行。现在的问题是每次我在 django 中启动线程时,新线程都位于新事务中。我将深入研究 django db 后端源代码以了解发生了什么,但也许有人可以解决这个问题。
太棒了;不同的线程可以在同一事务内执行查询吗?
是否可以关闭在Apps脚本中打开的UI窗口?
我认为答案是不对的:http://code.google.com/p/google-apps-script-issues/issues/detail?id = 474&can = 1&q =.close%28%29&cospec = Stors%20Opened%20ID %20Type%20Status%20Summary%20Component%20Owner
但我想知道是否还有其他意见.
我有一个弹出的"等待窗口",我希望在活动结束时关闭.
var app = UiApp.getActiveApplication();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = getSheetWithSubmissions(ss);
// create UI app, this works fine
app = createWaitPleaseUI(sheet);
ss.show(app);
//simulated activity
Utilities.sleep(5000);
//this doesn't work despite being in the documentation
app.close();
Run Code Online (Sandbox Code Playgroud)
认为这是不可能的,但希望谷歌如果无法完成,就会从文档中删除它.
作为一种解决方法,我可以调出第二个GUI,说"工作完成,单击确定"然后它工作正常.
python ×2
django ×1
gevent ×1
ios ×1
iphone ×1
postgresql ×1
python-3.4 ×1
pywin32 ×1
virtualenv ×1
windows ×1