Stop httputils service in basic4android - service

I am using basic4android and I made an application that uses httputils services. Sometimes a remote error occurs (possible server overload or limited internet connection) and the application exits with the error message box. The activity closes but httputils service is still running. While I reopen the activity new error occurs, because of the unfinished job of httputils. Everything is OK only if I choose to stop the activity in the second error.
Is there any way to determine if the httputils service is running by a previous instance of my app? Or better, a way to try to stop this service either its running or not.

HttpUtils errors should not cause your program to exit. You should check IsSuccess to make sure that the call succeeded or not.
You can stop the service from running by calling StopService(HttpUtilsService).

Public Sub StationTransfer_Click
Dim job As HttpJob
job.Initialize("MyJob", Me)
Dim URL As String="https://www.yourserver.com/myjob.asmx/GetData?parameter1=abc"
job.Download(URL)
ProgressDialogShow2("Getting data From Server...", True)
End Sub
Sub JobDone(Job As HttpJob)
Select Job.JobName
Case "MyJob"
HandleMyJob(Job)
End Select
Job.Release
End Sub
Sub HandleMyJob(Job As HttpJob)
If Job.Success = False Then
ToastMessageShow("Error downloading Data", True)
ProgressDialogHide
Return
End If
....
end Sub
if there is an httpjob error you catch it in the handler function by looking at the status. if the status is not success than you catch it and display a message.

Related

python Gtk app failed with this error xcb xlib threads sequence lost failed

I had a pyGObject app and I run that. all things work fine until on a button clicked signal I need to run a def. it has a long loop and I run that with the
def on_launch_btn_clicked(self,button):
_thread.start_new_thread(launch,["thread"])
def launch(thread):
lines_list = open("../line.txt").split()
for line in lines_list:
select = machinestate.objects.get(id=1)
if not select.pause:
#my process
else:
def pause_lcd()
return "pause" #it for come out of def and close thread but I don't know it close that or not
this loop is in another .py file
function it works like a charm, next I had a pause button it changes database pause field to True and my loop every iteration check database to saw what is changed. when it saw pause is True it run
def pause_lcd():
app = app_list[0]
app.pause_action()
I run Gtk app in this def
app_list = list()
def main(thread):
app = GUI()
app_list.append(app)
Gdk.threads_init()
Gtk.main()
in my GUI class I have pause_action method
def pause_action(self):
self.pause_btn.set_sensitive(True)
self.pause_btn.hide()
self.resume_btn.show()
when I clicked on pause button some time I got this error
[xcb] Unknown sequence number while processing queen
[xcb] Most likely this is a mulity-threaded client and XinitThreads has not been called
[xcb] Aborting, sorry about that
pyhton: ../../src/xcb_io.c:263 poll_for_event: Assertion '!xcb_xlib_threads_sequence_lost failed.
I had a bunch of thread side this threads like machine info, clock, machine temp and ...
what I do wrongs??
PS: this app run in a Django project and I use Django model in this it is an app of Django but it runs a Gtk app
I suspect that something with the XCB or the X11 server is wrong (bug). I received the same error message from different applications on a specific X server (using X11 over ssh).
Error message with emacs:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
emacs: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Error message with eclipse:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

MS-MPI MPI_Barrier: sometimes hangs indefinitely, sometimes doesn't

I'm using the MPI.NET library, and I've recently moved my application to a bigger cluster (more COMPUTE-NODES). I've started seeing various collective functions hang indefinitely, but only sometimes. About half the time a job will complete, the rest of the time it'll hang. I've seen it happen with Scatter, Broadcast, and Barrier.
I've put a MPI.Communicator.world.Barrier() call (MPI.NET) at the start of the application, and created trace logs (using the MPIEXEC.exe /trace switch).
C# code snippet:
static void Main(string[] args)
{
var hostName = System.Environment.MachineName;
Logger.Trace($"Program.Main entered on {hostName}");
string[] mpiArgs = null;
MPI.Environment myEnvironment = null;
try
{
Logger.Trace($"Trying to instantiated on MPI.Environment on {hostName}. Is currently initialized? {MPI.Environment.Initialized}");
myEnvironment = new MPI.Environment(ref mpiArgs);
Logger.Trace($"Is currently initialized?{MPI.Environment.Initialized}. {hostName} is waiting at Barrier... ");
Communicator.world.Barrier(); // CODE HANGS HERE!
Logger.Trace($"{hostName} is past Barrier");
}
catch (Exception envEx)
{
Logger.Error(envEx, "Could not instantiate MPI.Environment object");
}
// rest of implementation here...
}
I can see the msmpi.dll's MPI_Barrier function being called in the log, and I can see messages being sent and received thereafter for a passing and a failing example. For the passing example, messages are sent/received and then the MPI_Barrier function Leave is logged.
For the failing example it look like one (or more) of the send messages is lost - it is never received by the target. Am I correct in thinking that messages lost within the MPI_Barrier call will mean that the processes never synchronize, therefore all get stuck at the Communicator.world.Barrier() call?
What could be causing this to happen intermittently? Could poor network performance between the COMPUTE-NODES be a cause?
I'm running MS HPC Pack 2008 R2, so the version of MS-MPI is pretty old, v2.0.
EDIT - Additional information
If I keep a task running within the same node, then this issue does not happen. For example, if I run a task using 8 cores on one node then fine, but if i use 9 cores on two nodes I'll see this issue ~50% of the time.
Also, we have two clusters in use and this only happens on one of them. They are both virtualized environments, but appear to be set up identically.

PowerBuilder restart function

We are using Restart function in an application to close the application and re-open the same when the application is left idle for the specified period of time.
The fucntion works fine when we call the function from SDI application but when we call the function from MDI, the application closes off after couple of restarts.
In MDI frame, when the function is trigger is first time, the application restart works fine. When we leave the application for another idle time and the restart function is triggered again, the applicaiton just closes off. It does not crash or anything but just closes. Any idea on how to troubleshoot and solve the issue. Thanks.
One approach is after the idle event triggers, open a new instance of the application then close self.
This simple example is not designed to function in the IDE.
[PB external function declaration]
FUNCTION int GetModuleFileNameA(&
ulong hinstModule, &
REF string lpszPath, &
ulong cchPath) LIBRARY "kernel32" alias for "GetModuleFileNameA;ansi"
[in the application open event]
if commandline = "RESTARTED" then
messagebox( "Welcome Back!", "Click to Continue" )
end if
idle(300) // Restart the application if there is no activity for 5 minutes
Open ( w_main )
[in application IDLE event]
string ls_ExePathFileName
unsignedlong lul_handle
ls_ExePathFileName = space(1024)
lul_handle = Handle(GetApplication())
GetModuleFilenameA(lul_handle, ls_ExePathFileName, 1024)
run( ls_ExePathFileName + " RESTARTED" )
HALT CLOSE

Stop VFP from showing dialog boxes when errors occur

I am trying to call an existing VFP 6 application using Jacob which is a COM bridge for Java.
val vfp = new Application(new ActiveXComponent("VisualFoxPro.Application").getProperty("Application").toDispatch())
vfp.setVisible(false)
try {
vfp.doCmd("do my.exe with myconfig.txt")
} catch {
case t: Throwable => t.printStackTrace
} finally {
vfp.doCmd("close data")
vfp.doCmd("clear all")
vfp.doCmd("clear")
vfp.quit
vfp.safeRelease
}
When there are no error conditions this code executes well and generates the expected .dbfs. The problem is that when an error occurs (.dbf not found, file in use by another user, etc) a GUI window pops up and stops execution of the program until I use the mouse to cancel it. I want this program to run on a server with no user interaction so this won't work.
How can I gracefully handle the errors preferably without making a change to the VFP 6 program?
Since you have the source code for VFP6, I would suggest looking into
SYS(2335,0)
Sys 2335 is used to identify if the program is running in an "unattended" mode, any such popup dialog boxes will throw an error and prevent an actual "hit" ok/cancel/whatever button to continue. This includes popup window prompting user to pick a table.
I'm not positive of when it was made available as I had limited use of it. Like you, when dealing with a COM server under IIS and obviously nobody there to respond.
Start JVM in headless mode, catch HeadlessException or something. Or, write a Java program that will execute your GUI program using Runtime, and restart in a case of parsed errors in console.

Need Applescript to repeat every x number of seconds

Here is my script so far:
property timeDelay : 5
on appOpen(appName)
tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
return appNameIsRunning
end appOpen
if appOpen("iChat") then
tell application "iChat"
repeat with theService in services
if connection status of theService = disconnected or connection status of theService = disconnecting then
log in of service (name of theService)
end if
end repeat
end tell
end if
Basically, it checks a single time if any of your iChat/Messages accts are logged out. If they are, log them in. It works.
However, I would like this to be a 'Stay Open' app. In the past I've used the pattern
on idle
-- do stuff
end idle
..but for some reason it's erroring when I try to compile.
Any idea why this would be happening?
EDIT:
Ok -- still not sure why this was occurring, but I was able to fix the problem by simply making a new script. I have no idea why this error was coming up but it looks like it's good now. Thanks for the help guys.
This doesn't make sense...
tell application "System Events" to set appNameIsRunning to exists (processes where name is appName)
You want this...
tell application "System Events" to set appNameIsRunning to exists process appName
The reason is that "processes where name is appName" will return a list (whether it has one item or many it's still a list) and it makes no sense to check "exists" of a list.
I'm not sure about the error but I hope that solves your problem.
This works for me on 10.6.8
property timeDelay : 5
on appOpen(appName)
tell application "System Events" to set appNameIsRunning to exists process appName
return appNameIsRunning
end appOpen
on idle
if appOpen("iChat") then
tell application "iChat"
repeat with theService in services
if connection status of theService = disconnected or connection status of theService = disconnecting then
tell service (name of theService) to log in
end if
end repeat
end tell
end if
return timeDelay
end idle