Björn Swift schrieb:
> I've been playing around with comtypes for the last few days and ran
> into some trouble reading COM Properties. The COM in question is
> Microsoft.Hpc.Scheduler.Scheduler and this is the Python code
> executed:
> 
>>>> from comtypes.client import CreateObject
>>>> scheduler = CreateObject("Microsoft.Hpc.Scheduler.Scheduler")
>>>> scheduler.Connect("corecluster00")
>>>> job = scheduler.CreateJob()
>>>> task = job.CreateTask()
>>>> task.commandLine = r"mpiexec -n 4 ping -n 15 bjorns-ws"
>>>> job.AddTask(task)
>>>> scheduler.SubmitJob(job, None, None)


Björn, can you say a few words about what this hpc stuff is?  An add-on for
Windows Server 2008?

> Now we want to take a look at the job object and figure out the Job ID.
> 
>>>> job
> <POINTER(ISchedulerJob) ptr=0x767ffd0 at 3496770>
> 
>>>> job.id
> 124256112
> 
>>>> job.id
> 124256080
> 
>>>> job.id
> 124256048
> 
> Strange, an ever changing ID. Trying the _ISchedulerJob__com__get_id function:
> 
>>>> import ctypes
>>>> i = ctypes.c_long()
>>>> job._ISchedulerJob__com__get_id(ctypes.byref(i))
>>>> i
> c_long(124256016)
> 
>>>> job._ISchedulerJob__com__get_id(ctypes.byref(i))
>>>> i
> c_long(124255984)
> 
> Basically the same result.

Both the direct attribute access job.id and job._ISchedulerJob__com__get_id()
use the same mechanism internally, only the calling convention is different
so it is no wonder that they return the same result.

But what happens if I use IDispatch'ers Invoke ?
> 
>>>> job.Invoke(1610743834, _invkind=2)
> 184
> 
> Bingo, the correct job ID !
> 
> The same goes for other properties, such as job.State:
> 
>>>> job.State
> -1164233603
> 
>>>> job.Invoke(1610743851, _invkind=2)
> 128
> 
> 
> The dispatch ids are correct in the autogenerated Python classes (as
> per job.GetIDsOfNames output). I tried to chase down what was causing
> the error, but as I'm not familiar with comtypes internals I got a
> bit lost. I attempted to get from accessing job.id to IDispatch's
> Invoke() without luck.
> 
>>>> from comtypes.gen._C45D10A1_54E8_420B_A052_719D47EC7C16_0_2_0 import 
>>>> ISchedulerJob
>>>> ISchedulerJob.id
>>>> ISchedulerJob.id.fget
> <COM method offset 28: WinFunctionType at 0x03F964B8>
> 
> Does job.id perhaps not use the Dispatch interface ?

No, by default comtypes uses the custom interface when it is available.

> As there seems to be an issue with Microsoft.Hpc.Scheduler.dll (beta
> 2) causing my Python debugger to crash on breakpoints, tracing the
> steps from A to B therefore makes up for a fun manual labor
> step-through process ;) Perhaps you can identify the problem or point
> me in the right direction?

Can you please post the IDL of this interface, and also the generated code for 
it?
Maybe I'm able to spot something...

-- 
Thanks,
Thomas

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to